From be320368249fd09c5e6c425f32f2c39a48b1c4ef Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Thu, 7 Apr 2022 17:31:31 +0200 Subject: [PATCH] autocommit 2022-04-07 17:31:31 CEST --- build/build.rs | 10 +- build/egl.rs | 7 +- build/enums.rs | 9 +- build/tokens.rs | 6 +- build/wire.rs | 12 +- build/wire_dbus.rs | 21 ++- build/wire_xcon.rs | 19 ++- default-config/src/lib.rs | 43 +++-- jay-config/src/_private/client.rs | 41 +++-- jay-config/src/_private/ipc.rs | 21 ++- jay-config/src/_private/logging.rs | 6 +- jay-config/src/drm.rs | 15 +- jay-config/src/input.rs | 11 +- jay-config/src/keyboard/mod.rs | 9 +- jay-config/src/keyboard/mods.rs | 9 +- jay-config/src/lib.rs | 9 +- rustfmt.toml | 1 + src/acceptor.rs | 18 ++- src/async_engine.rs | 153 +++++++++++------- src/backend.rs | 11 +- src/backends/dummy.rs | 10 +- src/backends/metal.rs | 76 +++++---- src/backends/metal/input.rs | 24 +-- src/backends/metal/monitor.rs | 32 ++-- src/backends/metal/video.rs | 66 ++++---- src/backends/x.rs | 100 ++++++------ src/bugs.rs | 3 +- src/cli.rs | 10 +- src/cli/generate.rs | 8 +- src/cli/log.rs | 31 ++-- src/cli/quit.rs | 8 +- src/cli/set_log_level.rs | 12 +- src/client.rs | 55 ++++--- src/client/error.rs | 18 ++- src/client/objects.rs | 59 ++++--- src/client/tasks.rs | 24 +-- src/clientmem.rs | 19 ++- src/compositor.rs | 72 +++++---- src/config.rs | 38 +++-- src/config/handler.rs | 95 ++++++----- src/cursor.rs | 44 ++--- src/dbus.rs | 65 ++++---- src/dbus/auth.rs | 16 +- src/dbus/dynamic_type.rs | 13 +- src/dbus/formatter.rs | 9 +- src/dbus/holder.rs | 21 ++- src/dbus/incoming.rs | 29 ++-- src/dbus/outgoing.rs | 7 +- src/dbus/parser.rs | 16 +- src/dbus/property.rs | 7 +- src/dbus/socket.rs | 38 ++--- src/dbus/types.rs | 16 +- src/edid.rs | 16 +- src/event_loop.rs | 18 ++- src/fixed.rs | 6 +- src/forker.rs | 60 ++++--- src/forker/clone3.rs | 8 +- src/forker/io.rs | 25 +-- src/format.rs | 14 +- src/globals.rs | 62 ++++--- src/ifs/ipc.rs | 31 ++-- src/ifs/ipc/wl_data_device.rs | 39 ++--- src/ifs/ipc/wl_data_device_manager.rs | 25 +-- src/ifs/ipc/wl_data_offer.rs | 33 ++-- src/ifs/ipc/wl_data_source.rs | 38 +++-- ...zwp_primary_selection_device_manager_v1.rs | 28 ++-- .../ipc/zwp_primary_selection_device_v1.rs | 39 +++-- src/ifs/ipc/zwp_primary_selection_offer_v1.rs | 25 +-- .../ipc/zwp_primary_selection_source_v1.rs | 27 ++-- src/ifs/jay_compositor.rs | 27 ++-- src/ifs/jay_log_file.rs | 21 +-- src/ifs/org_kde_kwin_server_decoration.rs | 21 +-- .../org_kde_kwin_server_decoration_manager.rs | 24 +-- src/ifs/wl_buffer.rs | 33 ++-- src/ifs/wl_callback.rs | 17 +- src/ifs/wl_compositor.rs | 27 ++-- src/ifs/wl_display.rs | 25 +-- src/ifs/wl_drm.rs | 35 ++-- src/ifs/wl_output.rs | 46 +++--- src/ifs/wl_region.rs | 23 +-- src/ifs/wl_registry.rs | 22 +-- src/ifs/wl_seat.rs | 101 ++++++------ src/ifs/wl_seat/event_handling.rs | 102 +++++++----- src/ifs/wl_seat/kb_owner.rs | 13 +- src/ifs/wl_seat/pointer_owner.rs | 27 ++-- src/ifs/wl_seat/wl_keyboard.rs | 24 +-- src/ifs/wl_seat/wl_pointer.rs | 27 ++-- src/ifs/wl_seat/wl_touch.rs | 22 +-- src/ifs/wl_shm.rs | 26 +-- src/ifs/wl_shm_pool.rs | 32 ++-- src/ifs/wl_subcompositor.rs | 24 +-- src/ifs/wl_surface.rs | 92 +++++++---- src/ifs/wl_surface/cursor.rs | 18 ++- src/ifs/wl_surface/wl_subsurface.rs | 40 +++-- src/ifs/wl_surface/xdg_surface.rs | 58 +++---- src/ifs/wl_surface/xdg_surface/xdg_popup.rs | 51 +++--- .../wl_surface/xdg_surface/xdg_toplevel.rs | 70 ++++---- src/ifs/wl_surface/xwindow.rs | 82 +++++----- src/ifs/wl_surface/zwlr_layer_surface_v1.rs | 58 ++++--- src/ifs/xdg_positioner.rs | 27 ++-- src/ifs/xdg_wm_base.rs | 32 ++-- src/ifs/zwlr_layer_shell_v1.rs | 34 ++-- src/ifs/zwp_linux_buffer_params_v1.rs | 41 +++-- src/ifs/zwp_linux_dmabuf_v1.rs | 26 +-- src/ifs/zxdg_decoration_manager_v1.rs | 23 +-- src/ifs/zxdg_output_manager_v1.rs | 24 +-- src/ifs/zxdg_output_v1.rs | 21 +-- src/ifs/zxdg_toplevel_decoration_v1.rs | 21 +-- src/leaks.rs | 26 +-- src/libinput.rs | 50 +++--- src/libinput/device.rs | 25 +-- src/libinput/event.rs | 28 ++-- src/libinput/sys.rs | 3 +- src/logger.rs | 34 ++-- src/logind.rs | 22 ++- src/main.rs | 12 +- src/object.rs | 12 +- src/pango.rs | 16 +- src/rect.rs | 6 +- src/rect/region.rs | 18 +-- src/render.rs | 10 +- src/render/egl.rs | 40 ++--- src/render/egl/context.rs | 16 +- src/render/egl/display.rs | 58 ++++--- src/render/egl/image.rs | 12 +- src/render/ext.rs | 22 +-- src/render/gl/frame_buffer.rs | 25 +-- src/render/gl/program.rs | 24 +-- src/render/gl/render_buffer.rs | 25 +-- src/render/gl/shader.rs | 18 ++- src/render/gl/texture.rs | 37 +++-- src/render/renderer.rs | 6 +- src/render/renderer/context.rs | 43 ++--- src/render/renderer/framebuffer.rs | 32 ++-- src/render/renderer/image.rs | 10 +- src/render/renderer/renderer.rs | 52 +++--- src/render/renderer/texture.rs | 7 +- src/sighand.rs | 11 +- src/state.rs | 110 +++++++------ src/tasks.rs | 11 +- src/tasks/backend.rs | 12 +- src/tasks/connector.rs | 43 ++--- src/tasks/input_device.rs | 12 +- src/tasks/slow_clients.rs | 3 +- src/tasks/start_backend.rs | 14 +- src/text.rs | 29 ++-- src/time.rs | 16 +- src/tools/tool_client.rs | 70 ++++---- src/tree.rs | 151 +++-------------- src/tree/container.rs | 55 ++++--- src/tree/display.rs | 140 ++++++++++++++++ src/tree/float.rs | 43 ++--- src/tree/output.rs | 56 +++---- src/tree/toplevel.rs | 16 +- src/tree/walker.rs | 19 ++- src/tree/workspace.rs | 29 ++-- src/udev.rs | 11 +- src/utils/asyncevent.rs | 14 +- src/utils/buffd.rs | 13 +- src/utils/buffd/buf_in.rs | 13 +- src/utils/buffd/buf_out.rs | 23 +-- src/utils/buffd/formatter.rs | 16 +- src/utils/buffd/parser.rs | 16 +- src/utils/bufio.rs | 33 ++-- src/utils/clonecell.rs | 20 ++- src/utils/copyhashmap.rs | 24 +-- src/utils/errorfmt.rs | 6 +- src/utils/fdcloser.rs | 12 +- src/utils/linkedlist.rs | 18 ++- src/utils/nonblock.rs | 3 +- src/utils/numcell.rs | 8 +- src/utils/oserror.rs | 13 +- src/utils/queue.rs | 14 +- src/utils/run_toplevel.rs | 10 +- src/utils/smallmap.rs | 18 ++- src/utils/stack.rs | 6 +- src/utils/syncqueue.rs | 8 +- src/utils/tri.rs | 10 +- src/utils/vasprintf.rs | 12 +- src/utils/vec_ext.rs | 4 +- src/utils/vecstorage.rs | 6 +- src/{drm.rs => video.rs} | 0 src/{drm => video}/dma.rs | 4 +- src/{drm => video}/drm.rs | 60 +++---- src/{drm => video}/drm/sys.rs | 31 ++-- src/{drm => video}/gbm.rs | 26 +-- src/wheel.rs | 29 ++-- src/wire_xcon.rs | 11 +- src/xcon.rs | 84 +++++----- src/xcon/formatter.rs | 8 +- src/xcon/incoming.rs | 15 +- src/xcon/outgoing.rs | 7 +- src/xcon/parser.rs | 17 +- src/xcon/wire_type.rs | 14 +- src/xcon/xauthority.rs | 9 +- src/xkbcommon.rs | 25 +-- src/xwayland.rs | 39 ++--- src/xwayland/xsocket.rs | 13 +- src/xwayland/xwm.rs | 89 +++++----- wire-dbus/org.freedesktop.DBus.txt | 2 + 200 files changed, 3267 insertions(+), 2479 deletions(-) create mode 100644 rustfmt.toml create mode 100644 src/tree/display.rs rename src/{drm.rs => video.rs} (100%) rename src/{drm => video}/dma.rs (79%) rename src/{drm => video}/drm.rs (95%) rename src/{drm => video}/drm/sys.rs (97%) rename src/{drm => video}/gbm.rs (93%) diff --git a/build/build.rs b/build/build.rs index 1d97d571..3aa67608 100644 --- a/build/build.rs +++ b/build/build.rs @@ -13,10 +13,12 @@ extern crate core; -use std::fs::{File, OpenOptions}; -use std::io::BufWriter; -use std::path::PathBuf; -use std::{env, io}; +use std::{ + env, + fs::{File, OpenOptions}, + io::{self, BufWriter}, + path::PathBuf, +}; mod egl; mod enums; diff --git a/build/egl.rs b/build/egl.rs index aef86616..eef31de4 100644 --- a/build/egl.rs +++ b/build/egl.rs @@ -1,6 +1,7 @@ -use crate::open; -use std::fmt::Write as FmtWrite; -use std::io::Write; +use { + crate::open, + std::{fmt::Write as FmtWrite, io::Write}, +}; fn write_egl_procs(f: &mut W) -> anyhow::Result<()> { let map = [ diff --git a/build/enums.rs b/build/enums.rs index 7ec9bb49..ecaaf96c 100644 --- a/build/enums.rs +++ b/build/enums.rs @@ -1,7 +1,8 @@ -use crate::open; -use repc::layout::{Type, TypeVariant}; -use std::env; -use std::io::Write; +use { + crate::open, + repc::layout::{Type, TypeVariant}, + std::{env, io::Write}, +}; #[allow(unused_macros)] #[macro_use] diff --git a/build/tokens.rs b/build/tokens.rs index 5f6c6e9e..a3c5987e 100644 --- a/build/tokens.rs +++ b/build/tokens.rs @@ -1,5 +1,7 @@ -use anyhow::{bail, Context, Result}; -use bstr::{BStr, BString, ByteSlice}; +use { + anyhow::{bail, Context, Result}, + bstr::{BStr, BString, ByteSlice}, +}; #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum TreeDelim { diff --git a/build/wire.rs b/build/wire.rs index ae345cff..33d0b00a 100644 --- a/build/wire.rs +++ b/build/wire.rs @@ -1,9 +1,9 @@ -use crate::open; -use anyhow::{bail, Context, Result}; -use bstr::{BStr, BString, ByteSlice}; -use std::fs::DirEntry; -use std::io::Write; -use std::os::unix::ffi::OsStrExt; +use { + crate::open, + anyhow::{bail, Context, Result}, + bstr::{BStr, BString, ByteSlice}, + std::{fs::DirEntry, io::Write, os::unix::ffi::OsStrExt}, +}; #[derive(Copy, Clone, Debug, Eq, PartialEq)] enum TreeDelim { diff --git a/build/wire_dbus.rs b/build/wire_dbus.rs index 9b9d34fa..1603a97b 100644 --- a/build/wire_dbus.rs +++ b/build/wire_dbus.rs @@ -1,11 +1,16 @@ -use crate::open; -use crate::tokens::{tokenize, Lined, Symbol, Token, TokenKind, TreeDelim}; -use anyhow::{bail, Context, Result}; -use bstr::{BStr, BString, ByteSlice}; -use std::collections::hash_map::Entry; -use std::collections::HashMap; -use std::io::Write; -use std::os::unix::ffi::OsStrExt; +use { + crate::{ + open, + tokens::{tokenize, Lined, Symbol, Token, TokenKind, TreeDelim}, + }, + anyhow::{bail, Context, Result}, + bstr::{BStr, BString, ByteSlice}, + std::{ + collections::{hash_map::Entry, HashMap}, + io::Write, + os::unix::ffi::OsStrExt, + }, +}; #[derive(Debug)] enum Type { diff --git a/build/wire_xcon.rs b/build/wire_xcon.rs index 2ddb968b..59fbac2b 100644 --- a/build/wire_xcon.rs +++ b/build/wire_xcon.rs @@ -1,13 +1,12 @@ -use crate::open; -use crate::tokens::{tokenize, Symbol, Token, TokenKind, TreeDelim}; -use anyhow::{bail, Context, Result}; -use bstr::{BStr, BString, ByteSlice}; -use std::cell::Cell; -use std::collections::HashMap; -use std::io::Write; -use std::mem; -use std::os::unix::ffi::OsStrExt; -use std::rc::Rc; +use { + crate::{ + open, + tokens::{tokenize, Symbol, Token, TokenKind, TreeDelim}, + }, + anyhow::{bail, Context, Result}, + bstr::{BStr, BString, ByteSlice}, + std::{cell::Cell, collections::HashMap, io::Write, mem, os::unix::ffi::OsStrExt, rc::Rc}, +}; struct Parser<'a> { pos: usize, diff --git a/default-config/src/lib.rs b/default-config/src/lib.rs index 55e0ba5c..addf85a2 100644 --- a/default-config/src/lib.rs +++ b/default-config/src/lib.rs @@ -1,17 +1,26 @@ -use jay_config::drm::{get_connector, on_connector_connected, on_new_connector}; -use jay_config::embedded::grab_input_device; -use jay_config::input::capability::{CAP_KEYBOARD, CAP_POINTER}; -use jay_config::input::{create_seat, input_devices, on_new_input_device, InputDevice, Seat}; -use jay_config::keyboard::mods::{Modifiers, ALT, CTRL, SHIFT}; -use jay_config::keyboard::syms::{ - SYM_Super_L, SYM_b, SYM_d, SYM_f, SYM_h, SYM_j, SYM_k, SYM_l, SYM_m, SYM_p, SYM_q, SYM_t, - SYM_v, SYM_y, SYM_F1, SYM_F10, SYM_F11, SYM_F12, SYM_F13, SYM_F14, SYM_F15, SYM_F16, SYM_F17, - SYM_F18, SYM_F19, SYM_F2, SYM_F20, SYM_F21, SYM_F22, SYM_F23, SYM_F24, SYM_F25, SYM_F3, SYM_F4, - SYM_F5, SYM_F6, SYM_F7, SYM_F8, SYM_F9, +use jay_config::{ + config, + drm::{get_connector, on_connector_connected, on_new_connector}, + embedded::grab_input_device, + get_workspace, + input::{ + capability::{CAP_KEYBOARD, CAP_POINTER}, + create_seat, input_devices, on_new_input_device, InputDevice, Seat, + }, + keyboard::{ + mods::{Modifiers, ALT, CTRL, SHIFT}, + syms::{ + SYM_Super_L, SYM_b, SYM_d, SYM_f, SYM_h, SYM_j, SYM_k, SYM_l, SYM_m, SYM_p, SYM_q, + SYM_t, SYM_v, SYM_y, SYM_F1, SYM_F10, SYM_F11, SYM_F12, SYM_F13, SYM_F14, SYM_F15, + SYM_F16, SYM_F17, SYM_F18, SYM_F19, SYM_F2, SYM_F20, SYM_F21, SYM_F22, SYM_F23, + SYM_F24, SYM_F25, SYM_F3, SYM_F4, SYM_F5, SYM_F6, SYM_F7, SYM_F8, SYM_F9, + }, + }, + quit, switch_to_vt, + Axis::{Horizontal, Vertical}, + Command, + Direction::{Down, Left, Right, Up}, }; -use jay_config::Axis::{Horizontal, Vertical}; -use jay_config::Direction::{Down, Left, Right, Up}; -use jay_config::{config, get_workspace, quit, switch_to_vt, Command}; const MOD: Modifiers = ALT; @@ -95,7 +104,7 @@ pub fn configure() { input_devices().into_iter().for_each(handle_input_device); on_new_input_device(handle_input_device); - let connectors_changed = || { + let handle_connectors_changed = || { let left = get_connector("HDMI-A-1"); let right = get_connector("DP-1"); if left.connected() && right.connected() { @@ -103,9 +112,9 @@ pub fn configure() { right.set_position(left.width(), 0); } }; - on_new_connector(move |_| connectors_changed()); - on_connector_connected(move |_| connectors_changed()); - connectors_changed(); + on_new_connector(move |_| handle_connectors_changed()); + on_connector_connected(move |_| handle_connectors_changed()); + handle_connectors_changed(); } config!(configure); diff --git a/jay-config/src/_private/client.rs b/jay-config/src/_private/client.rs index a450838b..2e635bf2 100644 --- a/jay-config/src/_private/client.rs +++ b/jay-config/src/_private/client.rs @@ -1,21 +1,30 @@ #![allow(clippy::declare_interior_mutable_const, clippy::type_complexity)] -use crate::_private::ipc::{ClientMessage, InitMessage, Response, ServerMessage}; -use crate::_private::{bincode_ops, logging, Config, ConfigEntry, ConfigEntryGen, VERSION}; -use crate::drm::connector_type::{ConnectorType, CON_UNKNOWN}; -use crate::drm::{Connector, Mode}; -use crate::input::acceleration::AccelProfile; -use crate::input::capability::Capability; -use crate::input::{InputDevice, Seat}; -use crate::keyboard::keymap::Keymap; -use crate::theme::Color; -use crate::{Axis, Command, Direction, LogLevel, ModifiedKeySym, Workspace}; -use std::cell::{Cell, RefCell}; -use std::collections::hash_map::Entry; -use std::collections::HashMap; -use std::ops::Deref; -use std::rc::Rc; -use std::{ptr, slice}; +use { + crate::{ + _private::{ + bincode_ops, + ipc::{ClientMessage, InitMessage, Response, ServerMessage}, + logging, Config, ConfigEntry, ConfigEntryGen, VERSION, + }, + drm::{ + connector_type::{ConnectorType, CON_UNKNOWN}, + Connector, Mode, + }, + input::{acceleration::AccelProfile, capability::Capability, InputDevice, Seat}, + keyboard::keymap::Keymap, + theme::Color, + Axis, Command, Direction, LogLevel, ModifiedKeySym, Workspace, + }, + std::{ + cell::{Cell, RefCell}, + collections::{hash_map::Entry, HashMap}, + ops::Deref, + ptr, + rc::Rc, + slice, + }, +}; pub(crate) struct Client { configure: extern "C" fn(), diff --git a/jay-config/src/_private/ipc.rs b/jay-config/src/_private/ipc.rs index 6f1ad38f..086cf591 100644 --- a/jay-config/src/_private/ipc.rs +++ b/jay-config/src/_private/ipc.rs @@ -1,14 +1,13 @@ -use crate::drm::connector_type::ConnectorType; -use crate::drm::Connector; -use crate::input::acceleration::AccelProfile; -use crate::input::capability::Capability; -use crate::input::{InputDevice, Seat}; -use crate::keyboard::keymap::Keymap; -use crate::keyboard::mods::Modifiers; -use crate::keyboard::syms::KeySym; -use crate::theme::Color; -use crate::{Axis, Direction, LogLevel, Workspace}; -use bincode::{BorrowDecode, Decode, Encode}; +use { + crate::{ + drm::{connector_type::ConnectorType, Connector}, + input::{acceleration::AccelProfile, capability::Capability, InputDevice, Seat}, + keyboard::{keymap::Keymap, mods::Modifiers, syms::KeySym}, + theme::Color, + Axis, Direction, LogLevel, Workspace, + }, + bincode::{BorrowDecode, Decode, Encode}, +}; #[derive(Encode, BorrowDecode, Debug)] pub enum ServerMessage { diff --git a/jay-config/src/_private/logging.rs b/jay-config/src/_private/logging.rs index e486c46c..04099810 100644 --- a/jay-config/src/_private/logging.rs +++ b/jay-config/src/_private/logging.rs @@ -1,5 +1,7 @@ -use crate::LogLevel; -use log::{Level, LevelFilter, Log, Metadata, Record}; +use { + crate::LogLevel, + log::{Level, LevelFilter, Log, Metadata, Record}, +}; pub fn init() { log::set_logger(&Logger).unwrap(); diff --git a/jay-config/src/drm.rs b/jay-config/src/drm.rs index 842f3e7e..2c233c91 100644 --- a/jay-config/src/drm.rs +++ b/jay-config/src/drm.rs @@ -1,10 +1,13 @@ -use crate::drm::connector_type::{ - ConnectorType, CON_9PIN_DIN, CON_COMPONENT, CON_COMPOSITE, CON_DISPLAY_PORT, CON_DPI, CON_DSI, - CON_DVIA, CON_DVID, CON_DVII, CON_EDP, CON_EMBEDDED_WINDOW, CON_HDMIA, CON_HDMIB, CON_LVDS, - CON_SPI, CON_SVIDEO, CON_TV, CON_UNKNOWN, CON_USB, CON_VGA, CON_VIRTUAL, CON_WRITEBACK, +use { + crate::drm::connector_type::{ + ConnectorType, CON_9PIN_DIN, CON_COMPONENT, CON_COMPOSITE, CON_DISPLAY_PORT, CON_DPI, + CON_DSI, CON_DVIA, CON_DVID, CON_DVII, CON_EDP, CON_EMBEDDED_WINDOW, CON_HDMIA, CON_HDMIB, + CON_LVDS, CON_SPI, CON_SVIDEO, CON_TV, CON_UNKNOWN, CON_USB, CON_VGA, CON_VIRTUAL, + CON_WRITEBACK, + }, + bincode::{Decode, Encode}, + std::str::FromStr, }; -use bincode::{Decode, Encode}; -use std::str::FromStr; #[derive(Encode, Decode, Copy, Clone, Debug, Hash, Eq, PartialEq)] pub struct Mode { diff --git a/jay-config/src/input.rs b/jay-config/src/input.rs index e00eb06a..4aa3c71a 100644 --- a/jay-config/src/input.rs +++ b/jay-config/src/input.rs @@ -1,10 +1,13 @@ pub mod acceleration; pub mod capability; -use crate::input::acceleration::AccelProfile; -use crate::input::capability::Capability; -use crate::{Axis, Direction, Keymap, ModifiedKeySym, Workspace}; -use bincode::{Decode, Encode}; +use { + crate::{ + input::{acceleration::AccelProfile, capability::Capability}, + Axis, Direction, Keymap, ModifiedKeySym, Workspace, + }, + bincode::{Decode, Encode}, +}; #[derive(Encode, Decode, Copy, Clone, Debug, Hash, Eq, PartialEq)] pub struct InputDevice(pub u64); diff --git a/jay-config/src/keyboard/mod.rs b/jay-config/src/keyboard/mod.rs index 43444161..f90a9208 100644 --- a/jay-config/src/keyboard/mod.rs +++ b/jay-config/src/keyboard/mod.rs @@ -1,7 +1,8 @@ -use crate::keyboard::mods::Modifiers; -use crate::keyboard::syms::KeySym; -use bincode::{Decode, Encode}; -use std::ops::{BitOr, BitOrAssign}; +use { + crate::keyboard::{mods::Modifiers, syms::KeySym}, + bincode::{Decode, Encode}, + std::ops::{BitOr, BitOrAssign}, +}; pub mod keymap; pub mod mods; diff --git a/jay-config/src/keyboard/mods.rs b/jay-config/src/keyboard/mods.rs index f363631c..cd9f72ed 100644 --- a/jay-config/src/keyboard/mods.rs +++ b/jay-config/src/keyboard/mods.rs @@ -1,7 +1,8 @@ -use crate::keyboard::syms::KeySym; -use crate::ModifiedKeySym; -use bincode::{Decode, Encode}; -use std::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign}; +use { + crate::{keyboard::syms::KeySym, ModifiedKeySym}, + bincode::{Decode, Encode}, + std::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign}, +}; #[derive(Encode, Decode, Copy, Clone, Eq, PartialEq, Default, Hash, Debug)] pub struct Modifiers(pub u32); diff --git a/jay-config/src/lib.rs b/jay-config/src/lib.rs index 4a6dca93..e914be9f 100644 --- a/jay-config/src/lib.rs +++ b/jay-config/src/lib.rs @@ -1,7 +1,8 @@ -use crate::keyboard::keymap::Keymap; -use crate::keyboard::ModifiedKeySym; -use bincode::{Decode, Encode}; -use std::collections::HashMap; +use { + crate::keyboard::{keymap::Keymap, ModifiedKeySym}, + bincode::{Decode, Encode}, + std::collections::HashMap, +}; #[macro_use] mod macros; diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 00000000..58b51174 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +imports_granularity = "One" diff --git a/src/acceptor.rs b/src/acceptor.rs index 8b562d90..fbf3d2f6 100644 --- a/src/acceptor.rs +++ b/src/acceptor.rs @@ -1,10 +1,14 @@ -use crate::client::ClientError; -use crate::event_loop::{EventLoopDispatcher, EventLoopError, EventLoopId}; -use crate::state::State; -use crate::utils::errorfmt::ErrorFmt; -use std::rc::Rc; -use thiserror::Error; -use uapi::{c, format_ustr, Errno, OwnedFd, Ustring}; +use { + crate::{ + client::ClientError, + event_loop::{EventLoopDispatcher, EventLoopError, EventLoopId}, + state::State, + utils::errorfmt::ErrorFmt, + }, + std::rc::Rc, + thiserror::Error, + uapi::{c, format_ustr, Errno, OwnedFd, Ustring}, +}; #[derive(Debug, Error)] pub enum AcceptorError { diff --git a/src/async_engine.rs b/src/async_engine.rs index 42b3f05d..2a7b47bd 100644 --- a/src/async_engine.rs +++ b/src/async_engine.rs @@ -1,19 +1,26 @@ -pub use crate::async_engine::yield_::Yield; -use crate::event_loop::{EventLoop, EventLoopError}; -use crate::utils::copyhashmap::CopyHashMap; -use crate::utils::numcell::NumCell; -use crate::wheel::{Wheel, WheelError}; -use fd::AsyncFdData; -pub use fd::{AsyncFd, FdStatus}; -use queue::{DispatchQueue, Dispatcher}; -use std::cell::{Cell, RefCell}; -use std::future::Future; -use std::rc::Rc; -pub use task::SpawnedFuture; -use thiserror::Error; -pub use timeout::Timeout; -use timeout::TimeoutData; -use uapi::OwnedFd; +pub use { + crate::async_engine::yield_::Yield, + fd::{AsyncFd, FdStatus}, + task::SpawnedFuture, + timeout::Timeout, +}; +use { + crate::{ + event_loop::{EventLoop, EventLoopError}, + utils::{copyhashmap::CopyHashMap, numcell::NumCell}, + wheel::{Wheel, WheelError}, + }, + fd::AsyncFdData, + queue::{DispatchQueue, Dispatcher}, + std::{ + cell::{Cell, RefCell}, + future::Future, + rc::Rc, + }, + thiserror::Error, + timeout::TimeoutData, + uapi::OwnedFd, +}; #[derive(Debug, Error)] pub enum AsyncError { @@ -110,11 +117,15 @@ impl AsyncEngine { } mod yield_ { - use crate::async_engine::queue::DispatchQueue; - use std::future::Future; - use std::pin::Pin; - use std::rc::Rc; - use std::task::{Context, Poll}; + use { + crate::async_engine::queue::DispatchQueue, + std::{ + future::Future, + pin::Pin, + rc::Rc, + task::{Context, Poll}, + }, + }; pub struct Yield { pub(super) iteration: u64, @@ -136,13 +147,17 @@ mod yield_ { } mod timeout { - use crate::wheel::{Wheel, WheelDispatcher, WheelId}; - use std::cell::{Cell, RefCell}; - use std::error::Error; - use std::future::Future; - use std::pin::Pin; - use std::rc::Rc; - use std::task::{Context, Poll, Waker}; + use { + crate::wheel::{Wheel, WheelDispatcher, WheelId}, + std::{ + cell::{Cell, RefCell}, + error::Error, + future::Future, + pin::Pin, + rc::Rc, + task::{Context, Poll, Waker}, + }, + }; pub(super) struct TimeoutData { pub expired: Cell, @@ -186,17 +201,24 @@ mod timeout { } mod task { - use crate::async_engine::queue::DispatchQueue; - use crate::async_engine::Phase; - use crate::utils::numcell::NumCell; - use crate::utils::ptr_ext::{MutPtrExt, PtrExt}; - use std::cell::{Cell, UnsafeCell}; - use std::future::Future; - use std::mem::ManuallyDrop; - use std::pin::Pin; - use std::ptr; - use std::rc::Rc; - use std::task::{Context, Poll, RawWaker, RawWakerVTable, Waker}; + use { + crate::{ + async_engine::{queue::DispatchQueue, Phase}, + utils::{ + numcell::NumCell, + ptr_ext::{MutPtrExt, PtrExt}, + }, + }, + std::{ + cell::{Cell, UnsafeCell}, + future::Future, + mem::ManuallyDrop, + pin::Pin, + ptr, + rc::Rc, + task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, + }, + }; #[must_use] pub struct SpawnedFuture { @@ -430,17 +452,20 @@ mod task { } mod queue { - use crate::async_engine::task::Runnable; - use crate::async_engine::{AsyncError, Phase, NUM_PHASES}; - use crate::event_loop::{EventLoop, EventLoopDispatcher, EventLoopId}; - use crate::utils::array; - use crate::utils::numcell::NumCell; - use crate::utils::syncqueue::SyncQueue; - use std::cell::{Cell, RefCell}; - use std::collections::VecDeque; - use std::error::Error; - use std::rc::Rc; - use std::task::Waker; + use { + crate::{ + async_engine::{task::Runnable, AsyncError, Phase, NUM_PHASES}, + event_loop::{EventLoop, EventLoopDispatcher, EventLoopId}, + utils::{array, numcell::NumCell, syncqueue::SyncQueue}, + }, + std::{ + cell::{Cell, RefCell}, + collections::VecDeque, + error::Error, + rc::Rc, + task::Waker, + }, + }; pub(super) struct Dispatcher { queue: Rc, @@ -538,17 +563,23 @@ mod queue { } mod fd { - use crate::async_engine::{AsyncEngine, AsyncError}; - use crate::event_loop::{EventLoop, EventLoopDispatcher, EventLoopError, EventLoopId}; - use crate::utils::numcell::NumCell; - use std::cell::{Cell, RefCell}; - use std::error::Error; - use std::fmt::{Debug, Formatter}; - use std::future::Future; - use std::pin::Pin; - use std::rc::Rc; - use std::task::{Context, Poll, Waker}; - use uapi::{c, OwnedFd}; + use { + crate::{ + async_engine::{AsyncEngine, AsyncError}, + event_loop::{EventLoop, EventLoopDispatcher, EventLoopError, EventLoopId}, + utils::numcell::NumCell, + }, + std::{ + cell::{Cell, RefCell}, + error::Error, + fmt::{Debug, Formatter}, + future::Future, + pin::Pin, + rc::Rc, + task::{Context, Poll, Waker}, + }, + uapi::{c, OwnedFd}, + }; type Queue = RefCell>>)>>; diff --git a/src/backend.rs b/src/backend.rs index 1c12d105..b9993356 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -1,7 +1,10 @@ -use crate::drm::drm::ConnectorType; -use crate::fixed::Fixed; -use std::fmt::{Debug, Display, Formatter}; -use std::rc::Rc; +use { + crate::{video::drm::ConnectorType, fixed::Fixed}, + std::{ + fmt::{Debug, Display, Formatter}, + rc::Rc, + }, +}; linear_ids!(ConnectorIds, ConnectorId); linear_ids!(InputDeviceIds, InputDeviceId); diff --git a/src/backends/dummy.rs b/src/backends/dummy.rs index d2c95a54..7fc3f715 100644 --- a/src/backends/dummy.rs +++ b/src/backends/dummy.rs @@ -1,6 +1,10 @@ -use crate::backend::{Backend, Connector, ConnectorEvent, ConnectorId, ConnectorKernelId}; -use crate::drm::drm::ConnectorType; -use std::rc::Rc; +use { + crate::{ + backend::{Backend, Connector, ConnectorEvent, ConnectorId, ConnectorKernelId}, + video::drm::ConnectorType, + }, + std::rc::Rc, +}; pub struct DummyBackend {} diff --git a/src/backends/metal.rs b/src/backends/metal.rs index b4ccc76a..e0248c81 100644 --- a/src/backends/metal.rs +++ b/src/backends/metal.rs @@ -2,40 +2,50 @@ mod input; mod monitor; mod video; -use crate::async_engine::{AsyncError, AsyncFd}; -use crate::backend::{ - Backend, InputDevice, InputDeviceAccelProfile, InputDeviceCapability, InputDeviceId, - InputEvent, KeyState, +use { + crate::{ + async_engine::{AsyncError, AsyncFd}, + backend::{ + Backend, InputDevice, InputDeviceAccelProfile, InputDeviceCapability, InputDeviceId, + InputEvent, KeyState, + }, + backends::metal::video::{MetalDrmDevice, PendingDrmDevice}, + dbus::DbusError, + video::{drm::DrmError, gbm::GbmError}, + libinput::{ + consts::{ + AccelProfile, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE, + LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT, LIBINPUT_DEVICE_CAP_GESTURE, + LIBINPUT_DEVICE_CAP_KEYBOARD, LIBINPUT_DEVICE_CAP_POINTER, + LIBINPUT_DEVICE_CAP_SWITCH, LIBINPUT_DEVICE_CAP_TABLET_PAD, + LIBINPUT_DEVICE_CAP_TABLET_TOOL, LIBINPUT_DEVICE_CAP_TOUCH, + }, + device::RegisteredDevice, + LibInput, LibInputAdapter, LibInputError, + }, + logind::{LogindError, Session}, + render::RenderError, + state::State, + udev::{Udev, UdevError, UdevMonitor}, + utils::{ + clonecell::{CloneCell, UnsafeCellCloneSafe}, + copyhashmap::CopyHashMap, + errorfmt::ErrorFmt, + oserror::OsError, + smallmap::SmallMap, + syncqueue::SyncQueue, + }, + }, + std::{ + cell::{Cell, RefCell}, + ffi::{CStr, CString}, + future::pending, + mem, + rc::Rc, + }, + thiserror::Error, + uapi::{c, OwnedFd}, }; -use crate::backends::metal::video::{MetalDrmDevice, PendingDrmDevice}; -use crate::dbus::DbusError; -use crate::drm::drm::DrmError; -use crate::drm::gbm::GbmError; -use crate::libinput::consts::{ - AccelProfile, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE, LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT, - LIBINPUT_DEVICE_CAP_GESTURE, LIBINPUT_DEVICE_CAP_KEYBOARD, LIBINPUT_DEVICE_CAP_POINTER, - LIBINPUT_DEVICE_CAP_SWITCH, LIBINPUT_DEVICE_CAP_TABLET_PAD, LIBINPUT_DEVICE_CAP_TABLET_TOOL, - LIBINPUT_DEVICE_CAP_TOUCH, -}; -use crate::libinput::device::RegisteredDevice; -use crate::libinput::{LibInput, LibInputAdapter, LibInputError}; -use crate::logind::{LogindError, Session}; -use crate::render::RenderError; -use crate::state::State; -use crate::udev::{Udev, UdevError, UdevMonitor}; -use crate::utils::clonecell::{CloneCell, UnsafeCellCloneSafe}; -use crate::utils::copyhashmap::CopyHashMap; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::oserror::OsError; -use crate::utils::smallmap::SmallMap; -use crate::utils::syncqueue::SyncQueue; -use std::cell::{Cell, RefCell}; -use std::ffi::{CStr, CString}; -use std::future::pending; -use std::mem; -use std::rc::Rc; -use thiserror::Error; -use uapi::{c, OwnedFd}; #[derive(Debug, Error)] pub enum MetalError { diff --git a/src/backends/metal/input.rs b/src/backends/metal/input.rs index 94c169c8..44d1f710 100644 --- a/src/backends/metal/input.rs +++ b/src/backends/metal/input.rs @@ -1,13 +1,19 @@ -use crate::async_engine::FdStatus; -use crate::backend::{InputEvent, KeyState, ScrollAxis}; -use crate::backends::metal::MetalBackend; -use crate::libinput::consts::{ - LIBINPUT_BUTTON_STATE_PRESSED, LIBINPUT_KEY_STATE_PRESSED, - LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, +use { + crate::{ + async_engine::FdStatus, + backend::{InputEvent, KeyState, ScrollAxis}, + backends::metal::MetalBackend, + libinput::{ + consts::{ + LIBINPUT_BUTTON_STATE_PRESSED, LIBINPUT_KEY_STATE_PRESSED, + LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, + }, + event::LibInputEvent, + }, + utils::errorfmt::ErrorFmt, + }, + std::rc::Rc, }; -use crate::libinput::event::LibInputEvent; -use crate::utils::errorfmt::ErrorFmt; -use std::rc::Rc; macro_rules! unpack { ($slf:expr, $ev:expr) => {{ diff --git a/src/backends/metal/monitor.rs b/src/backends/metal/monitor.rs index 880c2874..00dd7f89 100644 --- a/src/backends/metal/monitor.rs +++ b/src/backends/metal/monitor.rs @@ -1,17 +1,21 @@ -use crate::async_engine::FdStatus; -use crate::backend::BackendEvent; -use crate::backends::metal::video::{MetalDrmDevice, PendingDrmDevice}; -use crate::backends::metal::{MetalBackend, MetalDevice, MetalError, MetalInputDevice}; -use crate::dbus::TRUE; -use crate::drm::drm::DrmMaster; -use crate::udev::UdevDevice; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::nonblock::set_nonblock; -use crate::wire_dbus::org::freedesktop::login1::session::{PauseDevice, ResumeDevice}; -use bstr::ByteSlice; -use std::cell::Cell; -use std::rc::Rc; -use uapi::{c, OwnedFd}; +use { + crate::{ + async_engine::FdStatus, + backend::BackendEvent, + backends::metal::{ + video::{MetalDrmDevice, PendingDrmDevice}, + MetalBackend, MetalDevice, MetalError, MetalInputDevice, + }, + dbus::TRUE, + video::drm::DrmMaster, + udev::UdevDevice, + utils::{errorfmt::ErrorFmt, nonblock::set_nonblock}, + wire_dbus::org::freedesktop::login1::session::{PauseDevice, ResumeDevice}, + }, + bstr::ByteSlice, + std::{cell::Cell, rc::Rc}, + uapi::{c, OwnedFd}, +}; const DRM: &[u8] = b"drm"; const INPUT: &[u8] = b"input"; diff --git a/src/backends/metal/video.rs b/src/backends/metal/video.rs index 0c4c89c1..fa94b097 100644 --- a/src/backends/metal/video.rs +++ b/src/backends/metal/video.rs @@ -1,34 +1,40 @@ -use crate::async_engine::{AsyncFd, SpawnedFuture}; -use crate::backend::{ - BackendEvent, Connector, ConnectorEvent, ConnectorId, ConnectorKernelId, MonitorInfo, +use { + crate::{ + async_engine::{AsyncFd, SpawnedFuture}, + backend::{ + BackendEvent, Connector, ConnectorEvent, ConnectorId, ConnectorKernelId, MonitorInfo, + }, + backends::metal::{DrmId, MetalBackend, MetalError}, + video::{ + drm::{ + drm_mode_modeinfo, Change, ConnectorStatus, ConnectorType, DrmBlob, DrmConnector, + DrmCrtc, DrmEncoder, DrmError, DrmEvent, DrmFramebuffer, DrmMaster, DrmModeInfo, + DrmObject, DrmPlane, DrmProperty, DrmPropertyDefinition, DrmPropertyType, PropBlob, + DRM_CLIENT_CAP_ATOMIC, DRM_MODE_ATOMIC_ALLOW_MODESET, DRM_MODE_ATOMIC_NONBLOCK, + DRM_MODE_PAGE_FLIP_EVENT, + }, + gbm::{GbmDevice, GBM_BO_USE_RENDERING, GBM_BO_USE_SCANOUT}, + ModifiedFormat, INVALID_MODIFIER, + }, + edid::Descriptor, + format::{Format, XRGB8888}, + render::{Framebuffer, RenderContext}, + state::State, + utils::{ + bitflags::BitflagsExt, clonecell::CloneCell, debug_fn::debug_fn, errorfmt::ErrorFmt, + numcell::NumCell, oserror::OsError, syncqueue::SyncQueue, + }, + }, + ahash::{AHashMap, AHashSet}, + bstr::{BString, ByteSlice}, + std::{ + cell::Cell, + ffi::CString, + fmt::{Debug, Formatter}, + rc::Rc, + }, + uapi::c, }; -use crate::backends::metal::{DrmId, MetalBackend, MetalError}; -use crate::drm::drm::{ - drm_mode_modeinfo, Change, ConnectorStatus, ConnectorType, DrmBlob, DrmConnector, DrmCrtc, - DrmEncoder, DrmError, DrmEvent, DrmFramebuffer, DrmMaster, DrmModeInfo, DrmObject, DrmPlane, - DrmProperty, DrmPropertyDefinition, DrmPropertyType, PropBlob, DRM_CLIENT_CAP_ATOMIC, - DRM_MODE_ATOMIC_ALLOW_MODESET, DRM_MODE_ATOMIC_NONBLOCK, DRM_MODE_PAGE_FLIP_EVENT, -}; -use crate::drm::gbm::{GbmDevice, GBM_BO_USE_RENDERING, GBM_BO_USE_SCANOUT}; -use crate::drm::{ModifiedFormat, INVALID_MODIFIER}; -use crate::edid::Descriptor; -use crate::format::{Format, XRGB8888}; -use crate::render::{Framebuffer, RenderContext}; -use crate::state::State; -use crate::utils::bitflags::BitflagsExt; -use crate::utils::clonecell::CloneCell; -use crate::utils::debug_fn::debug_fn; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::numcell::NumCell; -use crate::utils::oserror::OsError; -use crate::utils::syncqueue::SyncQueue; -use ahash::{AHashMap, AHashSet}; -use bstr::{BString, ByteSlice}; -use std::cell::Cell; -use std::ffi::CString; -use std::fmt::{Debug, Formatter}; -use std::rc::Rc; -use uapi::c; pub struct PendingDrmDevice { pub id: DrmId, diff --git a/src/backends/x.rs b/src/backends/x.rs index ae94b8bc..051d63b9 100644 --- a/src/backends/x.rs +++ b/src/backends/x.rs @@ -1,49 +1,59 @@ -use crate::async_engine::{Phase, SpawnedFuture}; -use crate::backend::{ - Backend, BackendEvent, Connector, ConnectorEvent, ConnectorId, ConnectorKernelId, InputDevice, - InputDeviceAccelProfile, InputDeviceCapability, InputDeviceId, InputEvent, KeyState, Mode, - MonitorInfo, ScrollAxis, +use { + crate::{ + async_engine::{Phase, SpawnedFuture}, + backend::{ + Backend, BackendEvent, Connector, ConnectorEvent, ConnectorId, ConnectorKernelId, + InputDevice, InputDeviceAccelProfile, InputDeviceCapability, InputDeviceId, InputEvent, + KeyState, Mode, MonitorInfo, ScrollAxis, + }, + video::{ + drm::{ConnectorType, Drm, DrmError}, + gbm::{GbmDevice, GbmError, GBM_BO_USE_RENDERING}, + ModifiedFormat, INVALID_MODIFIER, + }, + fixed::Fixed, + format::XRGB8888, + render::{Framebuffer, RenderContext, RenderError}, + state::State, + utils::{ + clonecell::CloneCell, copyhashmap::CopyHashMap, errorfmt::ErrorFmt, numcell::NumCell, + queue::AsyncQueue, syncqueue::SyncQueue, + }, + wire_xcon::{ + ChangeProperty, ChangeWindowAttributes, ConfigureNotify, CreateCursor, CreatePixmap, + CreateWindow, CreateWindowValues, DestroyNotify, Dri3Open, Dri3PixmapFromBuffer, + Dri3QueryVersion, Extension, FreePixmap, MapWindow, PresentCompleteNotify, + PresentIdleNotify, PresentPixmap, PresentQueryVersion, PresentSelectInput, + XiButtonPress, XiButtonRelease, XiDeviceInfo, XiEnter, XiEventMask, + XiGetDeviceButtonMapping, XiGrabDevice, XiHierarchy, XiKeyPress, XiKeyRelease, + XiMotion, XiQueryDevice, XiQueryVersion, XiSelectEvents, XiUngrabDevice, + XkbPerClientFlags, XkbUseExtension, + }, + xcon::{ + consts::{ + ATOM_STRING, ATOM_WM_CLASS, EVENT_MASK_EXPOSURE, EVENT_MASK_STRUCTURE_NOTIFY, + EVENT_MASK_VISIBILITY_CHANGE, GRAB_MODE_ASYNC, GRAB_STATUS_SUCCESS, + INPUT_DEVICE_ALL, INPUT_DEVICE_ALL_MASTER, INPUT_DEVICE_TYPE_MASTER_KEYBOARD, + INPUT_HIERARCHY_MASK_MASTER_ADDED, INPUT_HIERARCHY_MASK_MASTER_REMOVED, + PRESENT_EVENT_MASK_COMPLETE_NOTIFY, PRESENT_EVENT_MASK_IDLE_NOTIFY, + PROP_MODE_REPLACE, WINDOW_CLASS_INPUT_OUTPUT, XI_EVENT_MASK_BUTTON_PRESS, + XI_EVENT_MASK_BUTTON_RELEASE, XI_EVENT_MASK_ENTER, XI_EVENT_MASK_FOCUS_IN, + XI_EVENT_MASK_FOCUS_OUT, XI_EVENT_MASK_HIERARCHY, XI_EVENT_MASK_KEY_PRESS, + XI_EVENT_MASK_KEY_RELEASE, XI_EVENT_MASK_LEAVE, XI_EVENT_MASK_MOTION, + XI_EVENT_MASK_TOUCH_BEGIN, XI_EVENT_MASK_TOUCH_END, XI_EVENT_MASK_TOUCH_UPDATE, + XKB_PER_CLIENT_FLAG_DETECTABLE_AUTO_REPEAT, + }, + Event, XEvent, Xcon, XconError, + }, + }, + std::{ + borrow::Cow, + cell::{Cell, RefCell}, + collections::VecDeque, + rc::Rc, + }, + thiserror::Error, }; -use crate::drm::drm::{ConnectorType, Drm, DrmError}; -use crate::drm::gbm::{GbmDevice, GbmError, GBM_BO_USE_RENDERING}; -use crate::drm::{ModifiedFormat, INVALID_MODIFIER}; -use crate::fixed::Fixed; -use crate::format::XRGB8888; -use crate::render::{Framebuffer, RenderContext, RenderError}; -use crate::state::State; -use crate::utils::clonecell::CloneCell; -use crate::utils::copyhashmap::CopyHashMap; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::numcell::NumCell; -use crate::utils::queue::AsyncQueue; -use crate::utils::syncqueue::SyncQueue; -use crate::wire_xcon::{ - ChangeProperty, ChangeWindowAttributes, ConfigureNotify, CreateCursor, CreatePixmap, - CreateWindow, CreateWindowValues, DestroyNotify, Dri3Open, Dri3PixmapFromBuffer, - Dri3QueryVersion, Extension, FreePixmap, MapWindow, PresentCompleteNotify, PresentIdleNotify, - PresentPixmap, PresentQueryVersion, PresentSelectInput, XiButtonPress, XiButtonRelease, - XiDeviceInfo, XiEnter, XiEventMask, XiGetDeviceButtonMapping, XiGrabDevice, XiHierarchy, - XiKeyPress, XiKeyRelease, XiMotion, XiQueryDevice, XiQueryVersion, XiSelectEvents, - XiUngrabDevice, XkbPerClientFlags, XkbUseExtension, -}; -use crate::xcon::consts::{ - ATOM_STRING, ATOM_WM_CLASS, EVENT_MASK_EXPOSURE, EVENT_MASK_STRUCTURE_NOTIFY, - EVENT_MASK_VISIBILITY_CHANGE, GRAB_MODE_ASYNC, GRAB_STATUS_SUCCESS, INPUT_DEVICE_ALL, - INPUT_DEVICE_ALL_MASTER, INPUT_DEVICE_TYPE_MASTER_KEYBOARD, INPUT_HIERARCHY_MASK_MASTER_ADDED, - INPUT_HIERARCHY_MASK_MASTER_REMOVED, PRESENT_EVENT_MASK_COMPLETE_NOTIFY, - PRESENT_EVENT_MASK_IDLE_NOTIFY, PROP_MODE_REPLACE, WINDOW_CLASS_INPUT_OUTPUT, - XI_EVENT_MASK_BUTTON_PRESS, XI_EVENT_MASK_BUTTON_RELEASE, XI_EVENT_MASK_ENTER, - XI_EVENT_MASK_FOCUS_IN, XI_EVENT_MASK_FOCUS_OUT, XI_EVENT_MASK_HIERARCHY, - XI_EVENT_MASK_KEY_PRESS, XI_EVENT_MASK_KEY_RELEASE, XI_EVENT_MASK_LEAVE, XI_EVENT_MASK_MOTION, - XI_EVENT_MASK_TOUCH_BEGIN, XI_EVENT_MASK_TOUCH_END, XI_EVENT_MASK_TOUCH_UPDATE, - XKB_PER_CLIENT_FLAG_DETECTABLE_AUTO_REPEAT, -}; -use crate::xcon::{Event, XEvent, Xcon, XconError}; -use std::borrow::Cow; -use std::cell::{Cell, RefCell}; -use std::collections::VecDeque; -use std::rc::Rc; -use thiserror::Error; #[derive(Debug, Error)] pub enum XBackendError { diff --git a/src/bugs.rs b/src/bugs.rs index fa2535d8..65909357 100644 --- a/src/bugs.rs +++ b/src/bugs.rs @@ -1,5 +1,4 @@ -use ahash::AHashMap; -use once_cell::sync::Lazy; +use {ahash::AHashMap, once_cell::sync::Lazy}; static BUGS: Lazy> = Lazy::new(|| { let mut map = AHashMap::new(); diff --git a/src/cli.rs b/src/cli.rs index 1f62795c..0aec16fc 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -3,10 +3,12 @@ mod log; mod quit; mod set_log_level; -use crate::compositor::start_compositor; -use ::log::Level; -use clap::{ArgEnum, Args, Parser, Subcommand}; -use clap_complete::Shell; +use { + crate::compositor::start_compositor, + ::log::Level, + clap::{ArgEnum, Args, Parser, Subcommand}, + clap_complete::Shell, +}; /// A wayland compositor. #[derive(Parser, Debug)] diff --git a/src/cli/generate.rs b/src/cli/generate.rs index fef27f20..edb2487d 100644 --- a/src/cli/generate.rs +++ b/src/cli/generate.rs @@ -1,6 +1,8 @@ -use crate::cli::{GenerateArgs, Jay}; -use clap::CommandFactory; -use std::io::stdout; +use { + crate::cli::{GenerateArgs, Jay}, + clap::CommandFactory, + std::io::stdout, +}; pub fn main(args: GenerateArgs) { let stdout = stdout(); diff --git a/src/cli/log.rs b/src/cli/log.rs index 3c122992..47bc807b 100644 --- a/src/cli/log.rs +++ b/src/cli/log.rs @@ -1,16 +1,21 @@ -use crate::cli::{GlobalArgs, LogArgs}; -use crate::tools::tool_client::{Handle, ToolClient}; -use crate::utils::errorfmt::ErrorFmt; -use crate::wire::{jay_compositor, jay_log_file}; -use bstr::{BString, ByteSlice}; -use jay_compositor::GetLogFile; -use jay_log_file::Path; -use std::cell::RefCell; -use std::ops::Deref; -use std::os::unix::process::CommandExt; -use std::process; -use std::process::Command; -use std::rc::Rc; +use { + crate::{ + cli::{GlobalArgs, LogArgs}, + tools::tool_client::{Handle, ToolClient}, + utils::errorfmt::ErrorFmt, + wire::{jay_compositor, jay_log_file}, + }, + bstr::{BString, ByteSlice}, + jay_compositor::GetLogFile, + jay_log_file::Path, + std::{ + cell::RefCell, + ops::Deref, + os::unix::process::CommandExt, + process::{self, Command}, + rc::Rc, + }, +}; pub fn main(global: GlobalArgs, args: LogArgs) { let tc = ToolClient::new(global.log_level.into()); diff --git a/src/cli/quit.rs b/src/cli/quit.rs index c5a699bd..a5d55b84 100644 --- a/src/cli/quit.rs +++ b/src/cli/quit.rs @@ -1,7 +1,7 @@ -use crate::cli::GlobalArgs; -use crate::tools::tool_client::ToolClient; -use crate::wire::jay_compositor::Quit; -use std::rc::Rc; +use { + crate::{cli::GlobalArgs, tools::tool_client::ToolClient, wire::jay_compositor::Quit}, + std::rc::Rc, +}; pub fn main(global: GlobalArgs) { let tc = ToolClient::new(global.log_level.into()); diff --git a/src/cli/set_log_level.rs b/src/cli/set_log_level.rs index cb9714bd..3bc17aad 100644 --- a/src/cli/set_log_level.rs +++ b/src/cli/set_log_level.rs @@ -1,7 +1,11 @@ -use crate::cli::{GlobalArgs, SetLogArgs}; -use crate::tools::tool_client::ToolClient; -use crate::wire::jay_compositor::SetLogLevel; -use std::rc::Rc; +use { + crate::{ + cli::{GlobalArgs, SetLogArgs}, + tools::tool_client::ToolClient, + wire::jay_compositor::SetLogLevel, + }, + std::rc::Rc, +}; pub fn main(global: GlobalArgs, args: SetLogArgs) { let tc = ToolClient::new(global.log_level.into()); diff --git a/src/client.rs b/src/client.rs index 9b58b1f9..a04ccda1 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1,29 +1,34 @@ -use crate::async_engine::{AsyncFd, SpawnedFuture}; -use crate::client::error::LookupError; -use crate::client::objects::Objects; -use crate::ifs::wl_callback::WlCallback; -use crate::ifs::wl_display::WlDisplay; -use crate::ifs::wl_registry::WlRegistry; -use crate::leaks::Tracker; -use crate::object::{Interface, Object, ObjectId, WL_DISPLAY_ID}; -use crate::state::State; -use crate::utils::asyncevent::AsyncEvent; -use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError, OutBufferSwapchain}; -use crate::utils::copyhashmap::Locked; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::numcell::NumCell; -use crate::utils::queue::AsyncQueue; -use crate::wire::WlRegistryId; -use crate::xwayland::XWaylandEvent; -use ahash::AHashMap; pub use error::{ClientError, ObjectError}; -use std::cell::{Cell, RefCell}; -use std::error::Error; -use std::fmt::{Debug, Display, Formatter}; -use std::mem; -use std::ops::DerefMut; -use std::rc::Rc; -use uapi::{c, OwnedFd}; +use { + crate::{ + async_engine::{AsyncFd, SpawnedFuture}, + client::{error::LookupError, objects::Objects}, + ifs::{wl_callback::WlCallback, wl_display::WlDisplay, wl_registry::WlRegistry}, + leaks::Tracker, + object::{Interface, Object, ObjectId, WL_DISPLAY_ID}, + state::State, + utils::{ + asyncevent::AsyncEvent, + buffd::{MsgFormatter, MsgParser, MsgParserError, OutBufferSwapchain}, + copyhashmap::Locked, + errorfmt::ErrorFmt, + numcell::NumCell, + queue::AsyncQueue, + }, + wire::WlRegistryId, + xwayland::XWaylandEvent, + }, + ahash::AHashMap, + std::{ + cell::{Cell, RefCell}, + error::Error, + fmt::{Debug, Display, Formatter}, + mem, + ops::DerefMut, + rc::Rc, + }, + uapi::{c, OwnedFd}, +}; mod error; mod objects; diff --git a/src/client/error.rs b/src/client/error.rs index e456473c..4ce59d4d 100644 --- a/src/client/error.rs +++ b/src/client/error.rs @@ -1,10 +1,14 @@ -use crate::async_engine::AsyncError; -use crate::client::ClientId; -use crate::object::{Interface, ObjectId}; -use crate::utils::buffd::{BufFdError, MsgParserError}; -use crate::wire::WlDisplayId; -use std::error::Error; -use thiserror::Error; +use { + crate::{ + async_engine::AsyncError, + client::ClientId, + object::{Interface, ObjectId}, + utils::buffd::{BufFdError, MsgParserError}, + wire::WlDisplayId, + }, + std::error::Error, + thiserror::Error, +}; #[derive(Debug, Error)] pub enum ClientError { diff --git a/src/client/objects.rs b/src/client/objects.rs index 6748ad10..126c61ce 100644 --- a/src/client/objects.rs +++ b/src/client/objects.rs @@ -1,29 +1,38 @@ -use crate::client::{Client, ClientError}; -use crate::ifs::ipc::wl_data_source::WlDataSource; -use crate::ifs::ipc::zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1; -use crate::ifs::wl_buffer::WlBuffer; -use crate::ifs::wl_display::WlDisplay; -use crate::ifs::wl_output::WlOutput; -use crate::ifs::wl_region::WlRegion; -use crate::ifs::wl_registry::WlRegistry; -use crate::ifs::wl_seat::WlSeat; -use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel; -use crate::ifs::wl_surface::xdg_surface::XdgSurface; -use crate::ifs::wl_surface::WlSurface; -use crate::ifs::xdg_positioner::XdgPositioner; -use crate::ifs::xdg_wm_base::XdgWmBase; -use crate::object::{Object, ObjectId}; -use crate::tree::Node; -use crate::utils::clonecell::CloneCell; -use crate::utils::copyhashmap::{CopyHashMap, Locked}; -use crate::wire::{ - WlBufferId, WlDataSourceId, WlOutputId, WlRegionId, WlRegistryId, WlSeatId, WlSurfaceId, - XdgPositionerId, XdgSurfaceId, XdgToplevelId, XdgWmBaseId, ZwpPrimarySelectionSourceV1Id, +use { + crate::{ + client::{Client, ClientError}, + ifs::{ + ipc::{ + wl_data_source::WlDataSource, + zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1, + }, + wl_buffer::WlBuffer, + wl_display::WlDisplay, + wl_output::WlOutput, + wl_region::WlRegion, + wl_registry::WlRegistry, + wl_seat::WlSeat, + wl_surface::{ + xdg_surface::{xdg_toplevel::XdgToplevel, XdgSurface}, + WlSurface, + }, + xdg_positioner::XdgPositioner, + xdg_wm_base::XdgWmBase, + }, + object::{Object, ObjectId}, + tree::Node, + utils::{ + clonecell::CloneCell, + copyhashmap::{CopyHashMap, Locked}, + }, + wire::{ + WlBufferId, WlDataSourceId, WlOutputId, WlRegionId, WlRegistryId, WlSeatId, + WlSurfaceId, XdgPositionerId, XdgSurfaceId, XdgToplevelId, XdgWmBaseId, + ZwpPrimarySelectionSourceV1Id, + }, + }, + std::{cell::RefCell, mem, ops::DerefMut, rc::Rc}, }; -use std::cell::RefCell; -use std::mem; -use std::ops::DerefMut; -use std::rc::Rc; pub struct Objects { pub display: CloneCell>>, diff --git a/src/client/tasks.rs b/src/client/tasks.rs index f1ed416b..fc0da5c8 100644 --- a/src/client/tasks.rs +++ b/src/client/tasks.rs @@ -1,13 +1,17 @@ -use crate::async_engine::Phase; -use crate::client::{Client, ClientError}; -use crate::object::ObjectId; -use crate::utils::buffd::{BufFdIn, BufFdOut, MsgParser}; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::vec_ext::VecExt; -use futures_util::{select, FutureExt}; -use std::collections::VecDeque; -use std::mem; -use std::rc::Rc; +use { + crate::{ + async_engine::Phase, + client::{Client, ClientError}, + object::ObjectId, + utils::{ + buffd::{BufFdIn, BufFdOut, MsgParser}, + errorfmt::ErrorFmt, + vec_ext::VecExt, + }, + }, + futures_util::{select, FutureExt}, + std::{collections::VecDeque, mem, rc::Rc}, +}; pub async fn client(data: Rc) { let mut recv = data.state.eng.spawn(receive(data.clone())).fuse(); diff --git a/src/clientmem.rs b/src/clientmem.rs index b75aad4c..81645d07 100644 --- a/src/clientmem.rs +++ b/src/clientmem.rs @@ -1,11 +1,14 @@ -use std::cell::{Cell, UnsafeCell}; -use std::mem::MaybeUninit; -use std::ptr; -use std::rc::Rc; -use std::sync::atomic::{compiler_fence, Ordering}; -use thiserror::Error; -use uapi::c; -use uapi::c::raise; +use { + std::{ + cell::{Cell, UnsafeCell}, + mem::MaybeUninit, + ptr, + rc::Rc, + sync::atomic::{compiler_fence, Ordering}, + }, + thiserror::Error, + uapi::{c, c::raise}, +}; #[derive(Debug, Error)] pub enum ClientMemError { diff --git a/src/compositor.rs b/src/compositor.rs index e278dcde..feada570 100644 --- a/src/compositor.rs +++ b/src/compositor.rs @@ -1,37 +1,40 @@ -use crate::acceptor::{Acceptor, AcceptorError}; -use crate::async_engine::{AsyncEngine, AsyncError, Phase}; -use crate::backends::dummy::DummyOutput; -use crate::cli::{GlobalArgs, RunArgs}; -use crate::client::Clients; -use crate::clientmem::ClientMemError; -use crate::config::ConfigProxy; -use crate::dbus::Dbus; -use crate::event_loop::{EventLoop, EventLoopError}; -use crate::globals::Globals; -use crate::ifs::wl_output::WlOutputGlobal; -use crate::ifs::wl_surface::NoneSurfaceExt; -use crate::logger::Logger; -use crate::render::RenderError; -use crate::sighand::SighandError; -use crate::state::{ConnectorData, State}; -use crate::tree::{ - container_layout, container_render_data, float_layout, float_titles, DisplayNode, NodeIds, - OutputNode, WorkspaceNode, +use { + crate::{ + acceptor::{Acceptor, AcceptorError}, + async_engine::{AsyncEngine, AsyncError, Phase}, + backend, + backends::dummy::DummyOutput, + cli::{GlobalArgs, RunArgs}, + client::Clients, + clientmem::{self, ClientMemError}, + config::ConfigProxy, + dbus::Dbus, + event_loop::{EventLoop, EventLoopError}, + forker, + globals::Globals, + ifs::{wl_output::WlOutputGlobal, wl_surface::NoneSurfaceExt}, + leaks, + logger::Logger, + render::{self, RenderError}, + sighand::{self, SighandError}, + state::{ConnectorData, State}, + tasks, + tree::{ + container_layout, container_render_data, float_layout, float_titles, DisplayNode, + NodeIds, OutputNode, WorkspaceNode, + }, + utils::{ + clonecell::CloneCell, errorfmt::ErrorFmt, fdcloser::FdCloser, queue::AsyncQueue, + run_toplevel::RunToplevel, + }, + wheel::{Wheel, WheelError}, + xkbcommon::XkbContext, + xwayland, + }, + forker::ForkerProxy, + std::{cell::Cell, ops::Deref, rc::Rc, sync::Arc}, + thiserror::Error, }; -use crate::utils::clonecell::CloneCell; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::fdcloser::FdCloser; -use crate::utils::queue::AsyncQueue; -use crate::utils::run_toplevel::RunToplevel; -use crate::wheel::{Wheel, WheelError}; -use crate::xkbcommon::XkbContext; -use crate::{backend, clientmem, forker, leaks, render, sighand, tasks, xwayland}; -use forker::ForkerProxy; -use std::cell::Cell; -use std::ops::Deref; -use std::rc::Rc; -use std::sync::Arc; -use thiserror::Error; pub const MAX_EXTENTS: i32 = (1 << 24) - 1; @@ -115,6 +118,7 @@ fn main_(forker: Rc, logger: Arc, _args: &RunArgs) -> Resul fdcloser: FdCloser::new(), logger, connectors: Default::default(), + outputs: Default::default(), }); { let dummy_output = Rc::new(OutputNode { @@ -125,9 +129,7 @@ fn main_(forker: Rc, logger: Arc, _args: &RunArgs) -> Resul connector: Rc::new(DummyOutput { id: state.connector_ids.next(), }), - monitor_info: Default::default(), handler: Cell::new(None), - node: Default::default(), connected: Cell::new(true), }), 0, diff --git a/src/config.rs b/src/config.rs index ec6f96ee..4c63c91c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,21 +1,27 @@ mod handler; -use crate::backend::{ConnectorId, InputDeviceId}; -use crate::config::handler::ConfigProxyHandler; -use crate::ifs::wl_seat::SeatId; -use crate::state::State; -use crate::utils::numcell::NumCell; -use crate::utils::ptr_ext::PtrExt; -use jay_config::_private::ipc::{InitMessage, ServerMessage, V1InitMessage}; -use jay_config::_private::{bincode_ops, ConfigEntry, VERSION}; -use jay_config::drm::Connector; -use jay_config::input::{InputDevice, Seat}; -use jay_config::keyboard::ModifiedKeySym; -use libloading::Library; -use std::cell::Cell; -use std::ptr; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + backend::{ConnectorId, InputDeviceId}, + config::handler::ConfigProxyHandler, + ifs::wl_seat::SeatId, + state::State, + utils::{numcell::NumCell, ptr_ext::PtrExt}, + }, + jay_config::{ + _private::{ + bincode_ops, + ipc::{InitMessage, ServerMessage, V1InitMessage}, + ConfigEntry, VERSION, + }, + drm::Connector, + input::{InputDevice, Seat}, + keyboard::ModifiedKeySym, + }, + libloading::Library, + std::{cell::Cell, ptr, rc::Rc}, + thiserror::Error, +}; #[derive(Debug, Error)] pub enum ConfigError { diff --git a/src/config/handler.rs b/src/config/handler.rs index bf9468ab..c7610695 100644 --- a/src/config/handler.rs +++ b/src/config/handler.rs @@ -1,37 +1,40 @@ -use crate::backend; -use crate::backend::{ - ConnectorId, InputDeviceAccelProfile, InputDeviceCapability, InputDeviceId, Mode, +use { + crate::{ + backend, + backend::{ConnectorId, InputDeviceAccelProfile, InputDeviceCapability, InputDeviceId}, + compositor::MAX_EXTENTS, + ifs::wl_seat::{SeatId, WlSeatGlobal}, + state::{ConnectorData, DeviceHandlerData, OutputData, State}, + tree::{ContainerNode, ContainerSplit, FloatNode, Node, NodeVisitorBase}, + utils::{ + copyhashmap::CopyHashMap, debug_fn::debug_fn, errorfmt::ErrorFmt, numcell::NumCell, + stack::Stack, + }, + xkbcommon::{XkbCommonError, XkbKeymap}, + }, + bincode::error::DecodeError, + jay_config::{ + _private::{ + bincode_ops, + ipc::{ClientMessage, Response, ServerMessage}, + }, + drm::Connector, + input::{ + acceleration::{AccelProfile, ACCEL_PROFILE_ADAPTIVE, ACCEL_PROFILE_FLAT}, + capability::{ + Capability, CAP_GESTURE, CAP_KEYBOARD, CAP_POINTER, CAP_SWITCH, CAP_TABLET_PAD, + CAP_TABLET_TOOL, CAP_TOUCH, + }, + InputDevice, Seat, + }, + keyboard::{keymap::Keymap, mods::Modifiers, syms::KeySym}, + Axis, Direction, LogLevel, Workspace, + }, + libloading::Library, + log::Level, + std::{cell::Cell, rc::Rc}, + thiserror::Error, }; -use crate::compositor::MAX_EXTENTS; -use crate::ifs::wl_seat::{SeatId, WlSeatGlobal}; -use crate::state::{ConnectorData, DeviceHandlerData, State}; -use crate::tree::walker::NodeVisitorBase; -use crate::tree::{ContainerNode, ContainerSplit, FloatNode, Node}; -use crate::utils::copyhashmap::CopyHashMap; -use crate::utils::debug_fn::debug_fn; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::numcell::NumCell; -use crate::utils::stack::Stack; -use crate::xkbcommon::{XkbCommonError, XkbKeymap}; -use bincode::error::DecodeError; -use jay_config::_private::bincode_ops; -use jay_config::_private::ipc::{ClientMessage, Response, ServerMessage}; -use jay_config::drm::Connector; -use jay_config::input::acceleration::{AccelProfile, ACCEL_PROFILE_ADAPTIVE, ACCEL_PROFILE_FLAT}; -use jay_config::input::capability::{ - Capability, CAP_GESTURE, CAP_KEYBOARD, CAP_POINTER, CAP_SWITCH, CAP_TABLET_PAD, - CAP_TABLET_TOOL, CAP_TOUCH, -}; -use jay_config::input::{InputDevice, Seat}; -use jay_config::keyboard::keymap::Keymap; -use jay_config::keyboard::mods::Modifiers; -use jay_config::keyboard::syms::KeySym; -use jay_config::{Axis, Direction, LogLevel, Workspace}; -use libloading::Library; -use log::Level; -use std::cell::Cell; -use std::rc::Rc; -use thiserror::Error; pub(super) struct ConfigProxyHandler { pub client_data: Cell<*const u8>, @@ -194,6 +197,17 @@ impl ConfigProxyHandler { } } + fn get_output(&self, connector: Connector) -> Result, CphError> { + let data = self + .state + .outputs + .get(&ConnectorId::from_raw(connector.0 as _)); + match data { + Some(d) => Ok(d), + _ => Err(CphError::OutputDoesNotExist(connector)), + } + } + fn get_seat(&self, seat: Seat) -> Result, CphError> { let seats = self.state.globals.seats.lock(); for seat_global in seats.values() { @@ -320,11 +334,8 @@ impl ConfigProxyHandler { } fn handle_connector_mode(&self, connector: Connector) -> Result<(), CphError> { - let connector = self.get_connector(connector)?; - let mut mode = Mode::default(); - if let Some(node) = connector.node.get() { - mode = node.global.mode.get(); - } + let connector = self.get_output(connector)?; + let mode = connector.node.global.mode.get(); self.respond(Response::ConnectorMode { width: mode.width, height: mode.height, @@ -339,13 +350,11 @@ impl ConfigProxyHandler { x: i32, y: i32, ) -> Result<(), CphError> { - let connector = self.get_connector(connector)?; + let connector = self.get_output(connector)?; if x < 0 || y < 0 || x > MAX_EXTENTS || y > MAX_EXTENTS { return Err(CphError::InvalidConnectorPosition(x, y)); } - if let Some(node) = connector.node.get() { - node.set_position(x, y); - } + connector.node.set_position(x, y); Ok(()) } @@ -774,6 +783,8 @@ enum CphError { DeviceDoesNotExist(InputDevice), #[error("Connector {0:?} does not exist")] ConnectorDoesNotExist(Connector), + #[error("Connector {0:?} does not exist or is not connected")] + OutputDoesNotExist(Connector), #[error("{0}x{1} is not a valid connector position")] InvalidConnectorPosition(i32, i32), #[error("Keymap {0:?} does not exist")] diff --git a/src/cursor.rs b/src/cursor.rs index e32fa76b..84b8c09f 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -1,22 +1,28 @@ -use crate::format::ARGB8888; -use crate::rect::Rect; -use crate::render::{RenderContext, RenderError, Renderer, Texture}; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::numcell::NumCell; -use ahash::AHashSet; -use bstr::{BStr, BString, ByteSlice, ByteVec}; -use byteorder::{LittleEndian, ReadBytesExt}; -use isnt::std_1::primitive::IsntSliceExt; -use std::cell::Cell; -use std::convert::TryInto; -use std::fmt::{Debug, Formatter}; -use std::fs::File; -use std::io::{BufRead, BufReader, Seek, SeekFrom}; -use std::mem::MaybeUninit; -use std::rc::Rc; -use std::{env, io, slice, str}; -use thiserror::Error; -use uapi::c; +use { + crate::{ + format::ARGB8888, + rect::Rect, + render::{RenderContext, RenderError, Renderer, Texture}, + utils::{errorfmt::ErrorFmt, numcell::NumCell}, + }, + ahash::AHashSet, + bstr::{BStr, BString, ByteSlice, ByteVec}, + byteorder::{LittleEndian, ReadBytesExt}, + isnt::std_1::primitive::IsntSliceExt, + std::{ + cell::Cell, + convert::TryInto, + env, + fmt::{Debug, Formatter}, + fs::File, + io::{self, BufRead, BufReader, Seek, SeekFrom}, + mem::MaybeUninit, + rc::Rc, + slice, str, + }, + thiserror::Error, + uapi::c, +}; const XCURSOR_MAGIC: u32 = 0x72756358; const XCURSOR_IMAGE_TYPE: u32 = 0xfffd0002; diff --git a/src/dbus.rs b/src/dbus.rs index c1f10bc6..eea76d04 100644 --- a/src/dbus.rs +++ b/src/dbus.rs @@ -1,25 +1,35 @@ -use crate::async_engine::{AsyncEngine, AsyncError, AsyncFd, SpawnedFuture}; -use crate::dbus::property::GetReply; -use crate::dbus::types::{ObjectPath, Signature, Variant}; -use crate::utils::bufio::{BufIo, BufIoError}; -use crate::utils::clonecell::CloneCell; -use crate::utils::copyhashmap::CopyHashMap; -use crate::utils::numcell::NumCell; -use crate::utils::run_toplevel::RunToplevel; -use crate::utils::vecstorage::VecStorage; -use ahash::AHashMap; -use std::borrow::Cow; -use std::cell::{Cell, RefCell}; -use std::fmt::{Debug, Display}; -use std::future::Future; -use std::marker::PhantomData; -use std::mem; -use std::pin::Pin; -use std::rc::Rc; -use std::task::{Context, Poll, Waker}; -use thiserror::Error; pub use types::*; -use uapi::OwnedFd; +use { + crate::{ + async_engine::{AsyncEngine, AsyncError, AsyncFd, SpawnedFuture}, + dbus::{ + property::GetReply, + types::{ObjectPath, Signature, Variant}, + }, + utils::{ + bufio::{BufIo, BufIoError}, + clonecell::CloneCell, + copyhashmap::CopyHashMap, + numcell::NumCell, + run_toplevel::RunToplevel, + vecstorage::VecStorage, + }, + }, + ahash::AHashMap, + std::{ + borrow::Cow, + cell::{Cell, RefCell}, + fmt::{Debug, Display}, + future::Future, + marker::PhantomData, + mem, + pin::Pin, + rc::Rc, + task::{Context, Poll, Waker}, + }, + thiserror::Error, + uapi::OwnedFd, +}; mod auth; mod dynamic_type; @@ -468,11 +478,12 @@ struct InterfaceSignalHandlers { } pub mod prelude { - pub use super::{ - types::{Bool, DictEntry, ObjectPath, Signature, Variant}, - DbusError, DbusType, Formatter, Message, MethodCall, Parser, Property, Signal, + pub use { + super::{ + types::{Bool, DictEntry, ObjectPath, Signature, Variant}, + DbusError, DbusType, Formatter, Message, MethodCall, Parser, Property, Signal, + }, + std::{borrow::Cow, rc::Rc}, + uapi::OwnedFd, }; - pub use std::borrow::Cow; - pub use std::rc::Rc; - pub use uapi::OwnedFd; } diff --git a/src/dbus/auth.rs b/src/dbus/auth.rs index d1a6ed16..9eb41b2e 100644 --- a/src/dbus/auth.rs +++ b/src/dbus/auth.rs @@ -1,11 +1,11 @@ -use crate::dbus::incoming::handle_incoming; -use crate::dbus::outgoing::handle_outgoing; -use crate::dbus::{DbusError, DbusSocket}; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::hex; -use std::io::Write; -use std::rc::Rc; -use uapi::{c, Errno}; +use { + crate::{ + dbus::{incoming::handle_incoming, outgoing::handle_outgoing, DbusError, DbusSocket}, + utils::{errorfmt::ErrorFmt, hex}, + }, + std::{io::Write, rc::Rc}, + uapi::{c, Errno}, +}; pub(super) async fn handle_auth(socket: Rc) { let mut auth = Auth { diff --git a/src/dbus/dynamic_type.rs b/src/dbus/dynamic_type.rs index ca4654d3..1ef06cca 100644 --- a/src/dbus/dynamic_type.rs +++ b/src/dbus/dynamic_type.rs @@ -1,10 +1,11 @@ -use super::{ - TY_ARRAY, TY_BOOLEAN, TY_BYTE, TY_DOUBLE, TY_INT16, TY_INT32, TY_INT64, TY_OBJECT_PATH, - TY_SIGNATURE, TY_STRING, TY_UINT16, TY_UINT32, TY_UINT64, TY_UNIX_FD, TY_VARIANT, +use { + super::{ + TY_ARRAY, TY_BOOLEAN, TY_BYTE, TY_DOUBLE, TY_INT16, TY_INT32, TY_INT64, TY_OBJECT_PATH, + TY_SIGNATURE, TY_STRING, TY_UINT16, TY_UINT32, TY_UINT64, TY_UNIX_FD, TY_VARIANT, + }, + crate::dbus::{types::Variant, DbusError, DynamicType, Parser}, + std::ops::Deref, }; -use crate::dbus::types::Variant; -use crate::dbus::{DbusError, DynamicType, Parser}; -use std::ops::Deref; impl DynamicType { pub fn from_signature<'a>(mut s: &'a [u8]) -> Result<(DynamicType, &'a [u8]), DbusError> { diff --git a/src/dbus/formatter.rs b/src/dbus/formatter.rs index 2119b9f3..e793f389 100644 --- a/src/dbus/formatter.rs +++ b/src/dbus/formatter.rs @@ -1,7 +1,8 @@ -use crate::dbus::types::Variant; -use crate::dbus::{DbusType, Formatter}; -use std::rc::Rc; -use uapi::{OwnedFd, Packed}; +use { + crate::dbus::{types::Variant, DbusType, Formatter}, + std::rc::Rc, + uapi::{OwnedFd, Packed}, +}; impl<'a> Formatter<'a> { pub fn new(fds: &'a mut Vec>, buf: &'a mut Vec) -> Self { diff --git a/src/dbus/holder.rs b/src/dbus/holder.rs index 68f320de..ae1060cb 100644 --- a/src/dbus/holder.rs +++ b/src/dbus/holder.rs @@ -1,14 +1,13 @@ -use crate::async_engine::AsyncEngine; -use crate::dbus::auth::handle_auth; -use crate::dbus::{DbusError, DbusHolder, DbusSocket}; -use crate::utils::bufio::BufIo; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::numcell::NumCell; -use crate::utils::run_toplevel::RunToplevel; -use crate::wire_dbus::org; -use std::cell::Cell; -use std::rc::Rc; -use uapi::c; +use { + crate::{ + async_engine::AsyncEngine, + dbus::{auth::handle_auth, DbusError, DbusHolder, DbusSocket}, + utils::{bufio::BufIo, errorfmt::ErrorFmt, numcell::NumCell, run_toplevel::RunToplevel}, + wire_dbus::org, + }, + std::{cell::Cell, rc::Rc}, + uapi::c, +}; impl DbusHolder { pub(super) fn get( diff --git a/src/dbus/incoming.rs b/src/dbus/incoming.rs index 855edae5..178fe1ff 100644 --- a/src/dbus/incoming.rs +++ b/src/dbus/incoming.rs @@ -1,16 +1,21 @@ -use super::{ - HDR_DESTINATION, HDR_ERROR_NAME, HDR_INTERFACE, HDR_MEMBER, HDR_PATH, HDR_REPLY_SERIAL, - HDR_SENDER, HDR_SIGNATURE, HDR_UNIX_FDS, +use { + super::{ + HDR_DESTINATION, HDR_ERROR_NAME, HDR_INTERFACE, HDR_MEMBER, HDR_PATH, HDR_REPLY_SERIAL, + HDR_SENDER, HDR_SIGNATURE, HDR_UNIX_FDS, + }, + crate::{ + dbus::{ + CallError, DbusError, DbusSocket, Headers, Parser, MSG_ERROR, MSG_METHOD_RETURN, + MSG_SIGNAL, + }, + utils::{ + bufio::BufIoIncoming, + errorfmt::ErrorFmt, + ptr_ext::{MutPtrExt, PtrExt}, + }, + }, + std::{cell::UnsafeCell, ops::Deref, rc::Rc}, }; -use crate::dbus::{ - CallError, DbusError, DbusSocket, Headers, Parser, MSG_ERROR, MSG_METHOD_RETURN, MSG_SIGNAL, -}; -use crate::utils::bufio::BufIoIncoming; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::ptr_ext::{MutPtrExt, PtrExt}; -use std::cell::UnsafeCell; -use std::ops::Deref; -use std::rc::Rc; pub async fn handle_incoming(socket: Rc) { let mut incoming = Incoming { diff --git a/src/dbus/outgoing.rs b/src/dbus/outgoing.rs index c79e911f..7be23bb2 100644 --- a/src/dbus/outgoing.rs +++ b/src/dbus/outgoing.rs @@ -1,6 +1,7 @@ -use crate::dbus::DbusSocket; -use crate::utils::errorfmt::ErrorFmt; -use std::rc::Rc; +use { + crate::{dbus::DbusSocket, utils::errorfmt::ErrorFmt}, + std::rc::Rc, +}; pub async fn handle_outgoing(socket: Rc) { if let Err(e) = socket.bufio.clone().outgoing().await { diff --git a/src/dbus/parser.rs b/src/dbus/parser.rs index df45c24e..535d9da7 100644 --- a/src/dbus/parser.rs +++ b/src/dbus/parser.rs @@ -1,10 +1,12 @@ -use crate::dbus::types::{Bool, ObjectPath, Signature, Variant, FALSE, TRUE}; -use crate::dbus::{DbusError, DbusType, DynamicType, Parser}; -use bstr::ByteSlice; -use std::borrow::Cow; -use std::mem; -use std::rc::Rc; -use uapi::{OwnedFd, Pod}; +use { + crate::dbus::{ + types::{Bool, ObjectPath, Signature, Variant, FALSE, TRUE}, + DbusError, DbusType, DynamicType, Parser, + }, + bstr::ByteSlice, + std::{borrow::Cow, mem, rc::Rc}, + uapi::{OwnedFd, Pod}, +}; impl<'a> Parser<'a> { pub fn new(buf: &'a [u8], fds: &'a [Rc]) -> Self { diff --git a/src/dbus/property.rs b/src/dbus/property.rs index c454d28e..651e1767 100644 --- a/src/dbus/property.rs +++ b/src/dbus/property.rs @@ -1,6 +1,7 @@ -use crate::dbus::{DbusError, DbusType, Formatter, Message, MethodCall, Parser}; -use std::borrow::Cow; -use std::marker::PhantomData; +use { + crate::dbus::{DbusError, DbusType, Formatter, Message, MethodCall, Parser}, + std::{borrow::Cow, marker::PhantomData}, +}; #[derive(Debug)] pub struct Get<'a, T: DbusType<'static>> { diff --git a/src/dbus/socket.rs b/src/dbus/socket.rs index 197928c7..f66a316b 100644 --- a/src/dbus/socket.rs +++ b/src/dbus/socket.rs @@ -1,23 +1,23 @@ -use crate::dbus::property::Get; -use crate::dbus::types::{ObjectPath, Signature, Variant}; -use crate::dbus::{ - AsyncProperty, AsyncReply, AsyncReplySlot, DbusError, DbusSocket, DbusType, Formatter, Headers, - InterfaceSignalHandlers, Message, MethodCall, Parser, Property, Reply, ReplyHandler, Signal, - SignalHandler, SignalHandlerApi, SignalHandlerData, BUS_DEST, BUS_PATH, HDR_DESTINATION, - HDR_INTERFACE, HDR_MEMBER, HDR_PATH, HDR_SIGNATURE, HDR_UNIX_FDS, MSG_METHOD_CALL, - NO_REPLY_EXPECTED, +use { + crate::{ + dbus::{ + property::Get, + types::{ObjectPath, Signature, Variant}, + AsyncProperty, AsyncReply, AsyncReplySlot, DbusError, DbusSocket, DbusType, Formatter, + Headers, InterfaceSignalHandlers, Message, MethodCall, Parser, Property, Reply, + ReplyHandler, Signal, SignalHandler, SignalHandlerApi, SignalHandlerData, BUS_DEST, + BUS_PATH, HDR_DESTINATION, HDR_INTERFACE, HDR_MEMBER, HDR_PATH, HDR_SIGNATURE, + HDR_UNIX_FDS, MSG_METHOD_CALL, NO_REPLY_EXPECTED, + }, + utils::{bufio::BufIoMessage, errorfmt::ErrorFmt}, + wire_dbus::org, + }, + std::{ + cell::Cell, collections::hash_map::Entry, fmt::Write, marker::PhantomData, mem, + ops::DerefMut, rc::Rc, + }, + uapi::c, }; -use crate::utils::bufio::BufIoMessage; -use crate::utils::errorfmt::ErrorFmt; -use crate::wire_dbus::org; -use std::cell::Cell; -use std::collections::hash_map::Entry; -use std::fmt::Write; -use std::marker::PhantomData; -use std::mem; -use std::ops::DerefMut; -use std::rc::Rc; -use uapi::c; impl DbusSocket { pub(super) fn kill(self: &Rc) { diff --git a/src/dbus/types.rs b/src/dbus/types.rs index ed18e672..3cc8b4e9 100644 --- a/src/dbus/types.rs +++ b/src/dbus/types.rs @@ -1,12 +1,12 @@ -use crate::dbus::{ - DbusError, DbusType, DynamicType, Formatter, Parser, TY_ARRAY, TY_BOOLEAN, TY_BYTE, TY_DOUBLE, - TY_INT16, TY_INT32, TY_INT64, TY_OBJECT_PATH, TY_SIGNATURE, TY_STRING, TY_UINT16, TY_UINT32, - TY_UINT64, TY_UNIX_FD, TY_VARIANT, +use { + crate::dbus::{ + DbusError, DbusType, DynamicType, Formatter, Parser, TY_ARRAY, TY_BOOLEAN, TY_BYTE, + TY_DOUBLE, TY_INT16, TY_INT32, TY_INT64, TY_OBJECT_PATH, TY_SIGNATURE, TY_STRING, + TY_UINT16, TY_UINT32, TY_UINT64, TY_UNIX_FD, TY_VARIANT, + }, + std::{borrow::Cow, ops::Deref, rc::Rc}, + uapi::{OwnedFd, Packed, Pod}, }; -use std::borrow::Cow; -use std::ops::Deref; -use std::rc::Rc; -use uapi::{OwnedFd, Packed, Pod}; macro_rules! consume_signature_body { ($s:expr, $ty:expr) => {{ diff --git a/src/edid.rs b/src/edid.rs index 523f9709..d360c0d3 100644 --- a/src/edid.rs +++ b/src/edid.rs @@ -1,10 +1,12 @@ -use crate::utils::bitflags::BitflagsExt; -use crate::utils::ptr_ext::PtrExt; -use crate::utils::stack::Stack; -use bstr::{BString, ByteSlice}; -use std::fmt::{Debug, Formatter}; -use std::rc::Rc; -use thiserror::Error; +use { + crate::utils::{bitflags::BitflagsExt, ptr_ext::PtrExt, stack::Stack}, + bstr::{BString, ByteSlice}, + std::{ + fmt::{Debug, Formatter}, + rc::Rc, + }, + thiserror::Error, +}; #[derive(Copy, Clone, Debug)] pub enum ColorBitDepth { diff --git a/src/event_loop.rs b/src/event_loop.rs index 436b4034..a97dcf6c 100644 --- a/src/event_loop.rs +++ b/src/event_loop.rs @@ -1,11 +1,13 @@ -use crate::utils::clonecell::UnsafeCellCloneSafe; -use crate::utils::copyhashmap::CopyHashMap; -use crate::utils::numcell::NumCell; -use std::cell::{Cell, RefCell}; -use std::collections::VecDeque; -use std::rc::Rc; -use thiserror::Error; -use uapi::{c, Errno, OwnedFd}; +use { + crate::utils::{clonecell::UnsafeCellCloneSafe, copyhashmap::CopyHashMap, numcell::NumCell}, + std::{ + cell::{Cell, RefCell}, + collections::VecDeque, + rc::Rc, + }, + thiserror::Error, + uapi::{c, Errno, OwnedFd}, +}; #[derive(Debug, Error)] pub enum EventLoopError { diff --git a/src/fixed.rs b/src/fixed.rs index 7efc2b41..a57ba10a 100644 --- a/src/fixed.rs +++ b/src/fixed.rs @@ -1,5 +1,7 @@ -use std::fmt::{Debug, Display, Formatter}; -use std::ops::{Add, AddAssign, Sub, SubAssign}; +use std::{ + fmt::{Debug, Display, Formatter}, + ops::{Add, AddAssign, Sub, SubAssign}, +}; #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] #[repr(transparent)] diff --git a/src/forker.rs b/src/forker.rs index f6d57a31..fbe2d8f5 100644 --- a/src/forker.rs +++ b/src/forker.rs @@ -1,32 +1,40 @@ mod clone3; mod io; -use crate::async_engine::{AsyncEngine, AsyncFd, SpawnedFuture}; -use crate::event_loop::EventLoop; -use crate::forker::clone3::{fork_with_pidfd, Forked}; -use crate::forker::io::{IoIn, IoOut}; -use crate::state::State; -use crate::utils::buffd::BufFdError; -use crate::utils::copyhashmap::CopyHashMap; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::numcell::NumCell; -use crate::utils::queue::AsyncQueue; -use crate::wheel::Wheel; -use crate::xwayland; -use bincode::error::{DecodeError, EncodeError}; -use bincode::{Decode, Encode}; -use jay_config::_private::bincode_ops; -use log::Level; -use std::cell::{Cell, RefCell}; -use std::env; -use std::ffi::OsStr; -use std::io::Read; -use std::io::Write; -use std::os::unix::ffi::OsStrExt; -use std::rc::{Rc, Weak}; -use std::task::{Poll, Waker}; -use thiserror::Error; -use uapi::{c, pipe2, Errno, Fd, IntoUstr, OwnedFd, UstrPtr}; +use { + crate::{ + async_engine::{AsyncEngine, AsyncFd, SpawnedFuture}, + event_loop::EventLoop, + forker::{ + clone3::{fork_with_pidfd, Forked}, + io::{IoIn, IoOut}, + }, + state::State, + utils::{ + buffd::BufFdError, copyhashmap::CopyHashMap, errorfmt::ErrorFmt, numcell::NumCell, + queue::AsyncQueue, + }, + wheel::Wheel, + xwayland, + }, + bincode::{ + error::{DecodeError, EncodeError}, + Decode, Encode, + }, + jay_config::_private::bincode_ops, + log::Level, + std::{ + cell::{Cell, RefCell}, + env, + ffi::OsStr, + io::{Read, Write}, + os::unix::ffi::OsStrExt, + rc::{Rc, Weak}, + task::{Poll, Waker}, + }, + thiserror::Error, + uapi::{c, pipe2, Errno, Fd, IntoUstr, OwnedFd, UstrPtr}, +}; pub struct ForkerProxy { pidfd: Rc, diff --git a/src/forker/clone3.rs b/src/forker/clone3.rs index 0e4804af..111f3571 100644 --- a/src/forker/clone3.rs +++ b/src/forker/clone3.rs @@ -1,6 +1,8 @@ -use crate::forker::ForkerError; -use std::mem; -use uapi::{c, OwnedFd}; +use { + crate::forker::ForkerError, + std::mem, + uapi::{c, OwnedFd}, +}; #[derive(Default, Copy, Clone)] #[allow(non_camel_case_types, dead_code)] diff --git a/src/forker/io.rs b/src/forker/io.rs index a8a9fd31..04877878 100644 --- a/src/forker/io.rs +++ b/src/forker/io.rs @@ -1,13 +1,20 @@ -use bincode::{Decode, Encode}; -use std::mem; -use std::rc::Rc; +use { + bincode::{Decode, Encode}, + std::{mem, rc::Rc}, +}; -use crate::async_engine::AsyncFd; -use crate::forker::ForkerError; -use crate::utils::buffd::{BufFdIn, BufFdOut}; -use crate::utils::vec_ext::VecExt; -use jay_config::_private::bincode_ops; -use uapi::OwnedFd; +use { + crate::{ + async_engine::AsyncFd, + forker::ForkerError, + utils::{ + buffd::{BufFdIn, BufFdOut}, + vec_ext::VecExt, + }, + }, + jay_config::_private::bincode_ops, + uapi::OwnedFd, +}; pub struct IoIn { incoming: BufFdIn, diff --git a/src/format.rs b/src/format.rs index ee89588d..d7fc1d30 100644 --- a/src/format.rs +++ b/src/format.rs @@ -1,8 +1,12 @@ -use crate::render::sys::{GLint, GL_BGRA_EXT, GL_UNSIGNED_BYTE}; -use crate::utils::debug_fn::debug_fn; -use ahash::AHashMap; -use once_cell::sync::Lazy; -use std::fmt::{Debug, Write}; +use { + crate::{ + render::sys::{GLint, GL_BGRA_EXT, GL_UNSIGNED_BYTE}, + utils::debug_fn::debug_fn, + }, + ahash::AHashMap, + once_cell::sync::Lazy, + std::fmt::{Debug, Write}, +}; #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct Format { diff --git a/src/globals.rs b/src/globals.rs index b4ebaefb..e8c7834e 100644 --- a/src/globals.rs +++ b/src/globals.rs @@ -1,28 +1,40 @@ -use crate::client::Client; -use crate::ifs::ipc::wl_data_device_manager::WlDataDeviceManagerGlobal; -use crate::ifs::ipc::zwp_primary_selection_device_manager_v1::ZwpPrimarySelectionDeviceManagerV1Global; -use crate::ifs::jay_compositor::JayCompositorGlobal; -use crate::ifs::org_kde_kwin_server_decoration_manager::OrgKdeKwinServerDecorationManagerGlobal; -use crate::ifs::wl_compositor::WlCompositorGlobal; -use crate::ifs::wl_drm::WlDrmGlobal; -use crate::ifs::wl_output::WlOutputGlobal; -use crate::ifs::wl_registry::WlRegistry; -use crate::ifs::wl_seat::WlSeatGlobal; -use crate::ifs::wl_shm::WlShmGlobal; -use crate::ifs::wl_subcompositor::WlSubcompositorGlobal; -use crate::ifs::xdg_wm_base::XdgWmBaseGlobal; -use crate::ifs::zwlr_layer_shell_v1::ZwlrLayerShellV1Global; -use crate::ifs::zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1Global; -use crate::ifs::zxdg_decoration_manager_v1::ZxdgDecorationManagerV1Global; -use crate::ifs::zxdg_output_manager_v1::ZxdgOutputManagerV1Global; -use crate::object::{Interface, ObjectId}; -use crate::state::State; -use crate::utils::copyhashmap::{CopyHashMap, Locked}; -use crate::utils::numcell::NumCell; -use std::error::Error; -use std::fmt::{Display, Formatter}; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::Client, + ifs::{ + ipc::{ + wl_data_device_manager::WlDataDeviceManagerGlobal, + zwp_primary_selection_device_manager_v1::ZwpPrimarySelectionDeviceManagerV1Global, + }, + jay_compositor::JayCompositorGlobal, + org_kde_kwin_server_decoration_manager::OrgKdeKwinServerDecorationManagerGlobal, + wl_compositor::WlCompositorGlobal, + wl_drm::WlDrmGlobal, + wl_output::WlOutputGlobal, + wl_registry::WlRegistry, + wl_seat::WlSeatGlobal, + wl_shm::WlShmGlobal, + wl_subcompositor::WlSubcompositorGlobal, + xdg_wm_base::XdgWmBaseGlobal, + zwlr_layer_shell_v1::ZwlrLayerShellV1Global, + zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1Global, + zxdg_decoration_manager_v1::ZxdgDecorationManagerV1Global, + zxdg_output_manager_v1::ZxdgOutputManagerV1Global, + }, + object::{Interface, ObjectId}, + state::State, + utils::{ + copyhashmap::{CopyHashMap, Locked}, + numcell::NumCell, + }, + }, + std::{ + error::Error, + fmt::{Display, Formatter}, + rc::Rc, + }, + thiserror::Error, +}; #[derive(Debug, Error)] pub enum GlobalsError { diff --git a/src/ifs/ipc.rs b/src/ifs/ipc.rs index 85d58552..a9c39d44 100644 --- a/src/ifs/ipc.rs +++ b/src/ifs/ipc.rs @@ -1,16 +1,21 @@ -use crate::client::{Client, ClientId, WaylandObject}; -use crate::ifs::wl_seat::WlSeatGlobal; -use crate::object::ObjectId; -use crate::utils::bitflags::BitflagsExt; -use crate::utils::clonecell::CloneCell; -use crate::utils::numcell::NumCell; -use crate::utils::smallmap::SmallMap; -use ahash::AHashSet; -use std::cell::{Cell, RefCell}; -use std::ops::Deref; -use std::rc::Rc; -use thiserror::Error; -use uapi::OwnedFd; +use { + crate::{ + client::{Client, ClientId, WaylandObject}, + ifs::wl_seat::WlSeatGlobal, + object::ObjectId, + utils::{ + bitflags::BitflagsExt, clonecell::CloneCell, numcell::NumCell, smallmap::SmallMap, + }, + }, + ahash::AHashSet, + std::{ + cell::{Cell, RefCell}, + ops::Deref, + rc::Rc, + }, + thiserror::Error, + uapi::OwnedFd, +}; pub mod wl_data_device; pub mod wl_data_device_manager; diff --git a/src/ifs/ipc/wl_data_device.rs b/src/ifs/ipc/wl_data_device.rs index e09d1ab9..9ccf8b6b 100644 --- a/src/ifs/ipc/wl_data_device.rs +++ b/src/ifs/ipc/wl_data_device.rs @@ -1,22 +1,25 @@ -use crate::client::{Client, ClientError, ClientId}; -use crate::fixed::Fixed; -use crate::ifs::ipc::wl_data_device_manager::WlDataDeviceManager; -use crate::ifs::ipc::wl_data_offer::WlDataOffer; -use crate::ifs::ipc::wl_data_source::WlDataSource; -use crate::ifs::ipc::{ - break_device_loops, destroy_device, DeviceData, OfferData, Role, SourceData, Vtable, +use { + crate::{ + client::{Client, ClientError, ClientId}, + fixed::Fixed, + ifs::{ + ipc::{ + break_device_loops, destroy_device, wl_data_device_manager::WlDataDeviceManager, + wl_data_offer::WlDataOffer, wl_data_source::WlDataSource, DeviceData, OfferData, + Role, SourceData, Vtable, + }, + wl_seat::{WlSeat, WlSeatError, WlSeatGlobal}, + wl_surface::{SurfaceRole, WlSurfaceError}, + }, + leaks::Tracker, + object::{Object, ObjectId}, + utils::buffd::{MsgParser, MsgParserError}, + wire::{wl_data_device::*, WlDataDeviceId, WlDataOfferId, WlSurfaceId}, + }, + std::rc::Rc, + thiserror::Error, + uapi::OwnedFd, }; -use crate::ifs::wl_seat::{WlSeat, WlSeatError, WlSeatGlobal}; -use crate::ifs::wl_surface::{SurfaceRole, WlSurfaceError}; -use crate::leaks::Tracker; -use crate::object::{Object, ObjectId}; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::wl_data_device::*; -use crate::wire::{WlDataDeviceId, WlDataOfferId, WlSurfaceId}; -use std::rc::Rc; -use thiserror::Error; -use uapi::OwnedFd; #[allow(dead_code)] const ROLE: u32 = 0; diff --git a/src/ifs/ipc/wl_data_device_manager.rs b/src/ifs/ipc/wl_data_device_manager.rs index 14a205da..cb485b84 100644 --- a/src/ifs/ipc/wl_data_device_manager.rs +++ b/src/ifs/ipc/wl_data_device_manager.rs @@ -1,15 +1,16 @@ -use crate::client::{Client, ClientError}; -use crate::globals::{Global, GlobalName}; -use crate::ifs::ipc::wl_data_device::WlDataDevice; -use crate::ifs::ipc::wl_data_source::WlDataSource; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::wl_data_device_manager::*; -use crate::wire::WlDataDeviceManagerId; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + globals::{Global, GlobalName}, + ifs::ipc::{wl_data_device::WlDataDevice, wl_data_source::WlDataSource}, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{wl_data_device_manager::*, WlDataDeviceManagerId}, + }, + std::rc::Rc, + thiserror::Error, +}; pub(super) const DND_NONE: u32 = 0; #[allow(dead_code)] diff --git a/src/ifs/ipc/wl_data_offer.rs b/src/ifs/ipc/wl_data_offer.rs index 0a8f44dc..6c009c0d 100644 --- a/src/ifs/ipc/wl_data_offer.rs +++ b/src/ifs/ipc/wl_data_offer.rs @@ -1,19 +1,22 @@ -use crate::client::{Client, ClientError}; -use crate::ifs::ipc::wl_data_device::WlDataDevice; -use crate::ifs::ipc::wl_data_device_manager::DND_ALL; -use crate::ifs::ipc::{ - break_offer_loops, destroy_offer, receive, OfferData, Role, OFFER_STATE_ACCEPTED, - OFFER_STATE_DROPPED, OFFER_STATE_FINISHED, SOURCE_STATE_FINISHED, +use { + crate::{ + client::{Client, ClientError}, + ifs::ipc::{ + break_offer_loops, destroy_offer, receive, wl_data_device::WlDataDevice, + wl_data_device_manager::DND_ALL, OfferData, Role, OFFER_STATE_ACCEPTED, + OFFER_STATE_DROPPED, OFFER_STATE_FINISHED, SOURCE_STATE_FINISHED, + }, + leaks::Tracker, + object::Object, + utils::{ + bitflags::BitflagsExt, + buffd::{MsgParser, MsgParserError}, + }, + wire::{wl_data_offer::*, WlDataOfferId}, + }, + std::rc::Rc, + thiserror::Error, }; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::bitflags::BitflagsExt; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::wl_data_offer::*; -use crate::wire::WlDataOfferId; -use std::rc::Rc; -use thiserror::Error; #[allow(dead_code)] const INVALID_FINISH: u32 = 0; diff --git a/src/ifs/ipc/wl_data_source.rs b/src/ifs/ipc/wl_data_source.rs index 445f0a1d..4a8e337c 100644 --- a/src/ifs/ipc/wl_data_source.rs +++ b/src/ifs/ipc/wl_data_source.rs @@ -1,21 +1,25 @@ -use crate::client::{Client, ClientError}; -use crate::ifs::ipc::wl_data_device::WlDataDevice; -use crate::ifs::ipc::wl_data_device_manager::{DND_ALL, DND_NONE}; -use crate::ifs::ipc::wl_data_offer::WlDataOffer; -use crate::ifs::ipc::{ - add_mime_type, break_source_loops, cancel_offers, destroy_source, SharedState, SourceData, - OFFER_STATE_ACCEPTED, OFFER_STATE_DROPPED, +use { + crate::{ + client::{Client, ClientError}, + ifs::ipc::{ + add_mime_type, break_source_loops, cancel_offers, destroy_source, + wl_data_device::WlDataDevice, + wl_data_device_manager::{DND_ALL, DND_NONE}, + wl_data_offer::WlDataOffer, + SharedState, SourceData, OFFER_STATE_ACCEPTED, OFFER_STATE_DROPPED, + }, + leaks::Tracker, + object::Object, + utils::{ + bitflags::BitflagsExt, + buffd::{MsgParser, MsgParserError}, + }, + wire::{wl_data_source::*, WlDataSourceId}, + }, + std::rc::Rc, + thiserror::Error, + uapi::OwnedFd, }; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::bitflags::BitflagsExt; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::wl_data_source::*; -use crate::wire::WlDataSourceId; -use std::rc::Rc; -use thiserror::Error; -use uapi::OwnedFd; #[allow(dead_code)] const INVALID_ACTION_MASK: u32 = 0; diff --git a/src/ifs/ipc/zwp_primary_selection_device_manager_v1.rs b/src/ifs/ipc/zwp_primary_selection_device_manager_v1.rs index c8a828be..72eb62fa 100644 --- a/src/ifs/ipc/zwp_primary_selection_device_manager_v1.rs +++ b/src/ifs/ipc/zwp_primary_selection_device_manager_v1.rs @@ -1,15 +1,19 @@ -use crate::client::{Client, ClientError}; -use crate::globals::{Global, GlobalName}; -use crate::ifs::ipc::zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1; -use crate::ifs::ipc::zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::zwp_primary_selection_device_manager_v1::*; -use crate::wire::ZwpPrimarySelectionDeviceManagerV1Id; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + globals::{Global, GlobalName}, + ifs::ipc::{ + zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1, + zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1, + }, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{zwp_primary_selection_device_manager_v1::*, ZwpPrimarySelectionDeviceManagerV1Id}, + }, + std::rc::Rc, + thiserror::Error, +}; pub struct ZwpPrimarySelectionDeviceManagerV1Global { name: GlobalName, diff --git a/src/ifs/ipc/zwp_primary_selection_device_v1.rs b/src/ifs/ipc/zwp_primary_selection_device_v1.rs index cb89f6ab..27201ee9 100644 --- a/src/ifs/ipc/zwp_primary_selection_device_v1.rs +++ b/src/ifs/ipc/zwp_primary_selection_device_v1.rs @@ -1,19 +1,28 @@ -use crate::client::{Client, ClientError, ClientId}; -use crate::ifs::ipc::zwp_primary_selection_device_manager_v1::ZwpPrimarySelectionDeviceManagerV1; -use crate::ifs::ipc::zwp_primary_selection_offer_v1::ZwpPrimarySelectionOfferV1; -use crate::ifs::ipc::zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1; -use crate::ifs::ipc::{ - break_device_loops, destroy_device, DeviceData, OfferData, Role, SourceData, Vtable, +use { + crate::{ + client::{Client, ClientError, ClientId}, + ifs::{ + ipc::{ + break_device_loops, destroy_device, + zwp_primary_selection_device_manager_v1::ZwpPrimarySelectionDeviceManagerV1, + zwp_primary_selection_offer_v1::ZwpPrimarySelectionOfferV1, + zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1, DeviceData, + OfferData, Role, SourceData, Vtable, + }, + wl_seat::{WlSeat, WlSeatError, WlSeatGlobal}, + }, + leaks::Tracker, + object::{Object, ObjectId}, + utils::buffd::{MsgParser, MsgParserError}, + wire::{ + zwp_primary_selection_device_v1::*, ZwpPrimarySelectionDeviceV1Id, + ZwpPrimarySelectionOfferV1Id, + }, + }, + std::rc::Rc, + thiserror::Error, + uapi::OwnedFd, }; -use crate::ifs::wl_seat::{WlSeat, WlSeatError, WlSeatGlobal}; -use crate::leaks::Tracker; -use crate::object::{Object, ObjectId}; -use crate::utils::buffd::{MsgParser, MsgParserError}; -use crate::wire::zwp_primary_selection_device_v1::*; -use crate::wire::{ZwpPrimarySelectionDeviceV1Id, ZwpPrimarySelectionOfferV1Id}; -use std::rc::Rc; -use thiserror::Error; -use uapi::OwnedFd; pub struct ZwpPrimarySelectionDeviceV1 { pub id: ZwpPrimarySelectionDeviceV1Id, diff --git a/src/ifs/ipc/zwp_primary_selection_offer_v1.rs b/src/ifs/ipc/zwp_primary_selection_offer_v1.rs index e5021fa7..d1f7bd71 100644 --- a/src/ifs/ipc/zwp_primary_selection_offer_v1.rs +++ b/src/ifs/ipc/zwp_primary_selection_offer_v1.rs @@ -1,13 +1,18 @@ -use crate::client::{Client, ClientError}; -use crate::ifs::ipc::zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1; -use crate::ifs::ipc::{break_offer_loops, destroy_offer, receive, OfferData}; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::{MsgParser, MsgParserError}; -use crate::wire::zwp_primary_selection_offer_v1::*; -use crate::wire::ZwpPrimarySelectionOfferV1Id; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + ifs::ipc::{ + break_offer_loops, destroy_offer, receive, + zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1, OfferData, + }, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{zwp_primary_selection_offer_v1::*, ZwpPrimarySelectionOfferV1Id}, + }, + std::rc::Rc, + thiserror::Error, +}; pub struct ZwpPrimarySelectionOfferV1 { pub id: ZwpPrimarySelectionOfferV1Id, diff --git a/src/ifs/ipc/zwp_primary_selection_source_v1.rs b/src/ifs/ipc/zwp_primary_selection_source_v1.rs index bbba0d18..05a461f6 100644 --- a/src/ifs/ipc/zwp_primary_selection_source_v1.rs +++ b/src/ifs/ipc/zwp_primary_selection_source_v1.rs @@ -1,14 +1,19 @@ -use crate::client::{Client, ClientError}; -use crate::ifs::ipc::zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1; -use crate::ifs::ipc::{add_mime_type, break_source_loops, destroy_source, SourceData}; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::{MsgParser, MsgParserError}; -use crate::wire::zwp_primary_selection_source_v1::*; -use crate::wire::ZwpPrimarySelectionSourceV1Id; -use std::rc::Rc; -use thiserror::Error; -use uapi::OwnedFd; +use { + crate::{ + client::{Client, ClientError}, + ifs::ipc::{ + add_mime_type, break_source_loops, destroy_source, + zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1, SourceData, + }, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{zwp_primary_selection_source_v1::*, ZwpPrimarySelectionSourceV1Id}, + }, + std::rc::Rc, + thiserror::Error, + uapi::OwnedFd, +}; pub struct ZwpPrimarySelectionSourceV1 { pub id: ZwpPrimarySelectionSourceV1Id, diff --git a/src/ifs/jay_compositor.rs b/src/ifs/jay_compositor.rs index d65b7b4a..115beb88 100644 --- a/src/ifs/jay_compositor.rs +++ b/src/ifs/jay_compositor.rs @@ -1,15 +1,18 @@ -use crate::cli::CliLogLevel; -use crate::client::{Client, ClientError}; -use crate::globals::{Global, GlobalName}; -use crate::ifs::jay_log_file::JayLogFile; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::{MsgParser, MsgParserError}; -use crate::wire::jay_compositor::*; -use crate::wire::JayCompositorId; -use log::Level; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + cli::CliLogLevel, + client::{Client, ClientError}, + globals::{Global, GlobalName}, + ifs::jay_log_file::JayLogFile, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{jay_compositor::*, JayCompositorId}, + }, + log::Level, + std::rc::Rc, + thiserror::Error, +}; pub struct JayCompositorGlobal { name: GlobalName, diff --git a/src/ifs/jay_log_file.rs b/src/ifs/jay_log_file.rs index 3bc9f2cd..8578ed65 100644 --- a/src/ifs/jay_log_file.rs +++ b/src/ifs/jay_log_file.rs @@ -1,12 +1,15 @@ -use crate::client::{Client, ClientError}; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::{MsgParser, MsgParserError}; -use crate::wire::jay_log_file::*; -use crate::wire::JayLogFileId; -use bstr::BStr; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{jay_log_file::*, JayLogFileId}, + }, + bstr::BStr, + std::rc::Rc, + thiserror::Error, +}; pub struct JayLogFile { pub id: JayLogFileId, diff --git a/src/ifs/org_kde_kwin_server_decoration.rs b/src/ifs/org_kde_kwin_server_decoration.rs index d2c6041c..2cf8996e 100644 --- a/src/ifs/org_kde_kwin_server_decoration.rs +++ b/src/ifs/org_kde_kwin_server_decoration.rs @@ -1,13 +1,14 @@ -use crate::client::{Client, ClientError}; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::org_kde_kwin_server_decoration::*; -use crate::wire::OrgKdeKwinServerDecorationId; -use std::cell::Cell; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{org_kde_kwin_server_decoration::*, OrgKdeKwinServerDecorationId}, + }, + std::{cell::Cell, rc::Rc}, + thiserror::Error, +}; #[allow(dead_code)] const NONE: u32 = 0; diff --git a/src/ifs/org_kde_kwin_server_decoration_manager.rs b/src/ifs/org_kde_kwin_server_decoration_manager.rs index 05b80a13..400407fe 100644 --- a/src/ifs/org_kde_kwin_server_decoration_manager.rs +++ b/src/ifs/org_kde_kwin_server_decoration_manager.rs @@ -1,14 +1,16 @@ -use crate::client::{Client, ClientError}; -use crate::globals::{Global, GlobalName}; -use crate::ifs::org_kde_kwin_server_decoration::OrgKdeKwinServerDecoration; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::org_kde_kwin_server_decoration_manager::*; -use crate::wire::OrgKdeKwinServerDecorationManagerId; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + globals::{Global, GlobalName}, + ifs::org_kde_kwin_server_decoration::OrgKdeKwinServerDecoration, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{org_kde_kwin_server_decoration_manager::*, OrgKdeKwinServerDecorationManagerId}, + }, + std::rc::Rc, + thiserror::Error, +}; #[allow(dead_code)] const NONE: u32 = 0; diff --git a/src/ifs/wl_buffer.rs b/src/ifs/wl_buffer.rs index 463da48d..6cc79930 100644 --- a/src/ifs/wl_buffer.rs +++ b/src/ifs/wl_buffer.rs @@ -1,18 +1,21 @@ -use crate::client::{Client, ClientError}; -use crate::clientmem::{ClientMem, ClientMemError, ClientMemOffset}; -use crate::format::Format; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::rect::Rect; -use crate::render::{Image, RenderError, Texture}; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::utils::clonecell::CloneCell; -use crate::wire::wl_buffer::*; -use crate::wire::WlBufferId; -use std::cell::Cell; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + clientmem::{ClientMem, ClientMemError, ClientMemOffset}, + format::Format, + leaks::Tracker, + object::Object, + rect::Rect, + render::{Image, RenderError, Texture}, + utils::{ + buffd::{MsgParser, MsgParserError}, + clonecell::CloneCell, + }, + wire::{wl_buffer::*, WlBufferId}, + }, + std::{cell::Cell, rc::Rc}, + thiserror::Error, +}; pub enum WlBufferStorage { Shm { mem: ClientMemOffset, stride: i32 }, diff --git a/src/ifs/wl_callback.rs b/src/ifs/wl_callback.rs index 067b2090..c3f3038c 100644 --- a/src/ifs/wl_callback.rs +++ b/src/ifs/wl_callback.rs @@ -1,10 +1,13 @@ -use crate::client::Client; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::wire::wl_callback::*; -use crate::wire::WlCallbackId; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::Client, + leaks::Tracker, + object::Object, + wire::{wl_callback::*, WlCallbackId}, + }, + std::rc::Rc, + thiserror::Error, +}; pub struct WlCallback { client: Rc, diff --git a/src/ifs/wl_compositor.rs b/src/ifs/wl_compositor.rs index 532494be..cc265aad 100644 --- a/src/ifs/wl_compositor.rs +++ b/src/ifs/wl_compositor.rs @@ -1,16 +1,17 @@ -use crate::client::{Client, ClientError}; -use crate::globals::{Global, GlobalName}; -use crate::ifs::wl_region::WlRegion; -use crate::ifs::wl_surface::WlSurface; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::wl_compositor::*; -use crate::wire::WlCompositorId; -use crate::xwayland::XWaylandEvent; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + globals::{Global, GlobalName}, + ifs::{wl_region::WlRegion, wl_surface::WlSurface}, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{wl_compositor::*, WlCompositorId}, + xwayland::XWaylandEvent, + }, + std::rc::Rc, + thiserror::Error, +}; pub struct WlCompositorGlobal { name: GlobalName, diff --git a/src/ifs/wl_display.rs b/src/ifs/wl_display.rs index 83ea6635..ca8d4bfb 100644 --- a/src/ifs/wl_display.rs +++ b/src/ifs/wl_display.rs @@ -1,15 +1,16 @@ -use crate::client::{Client, ClientError}; -use crate::globals::GlobalsError; -use crate::ifs::wl_callback::WlCallback; -use crate::ifs::wl_registry::WlRegistry; -use crate::leaks::Tracker; -use crate::object::{Object, ObjectId, WL_DISPLAY_ID}; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::wl_display::*; -use crate::wire::WlDisplayId; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + globals::GlobalsError, + ifs::{wl_callback::WlCallback, wl_registry::WlRegistry}, + leaks::Tracker, + object::{Object, ObjectId, WL_DISPLAY_ID}, + utils::buffd::{MsgParser, MsgParserError}, + wire::{wl_display::*, WlDisplayId}, + }, + std::rc::Rc, + thiserror::Error, +}; const INVALID_OBJECT: u32 = 0; const INVALID_METHOD: u32 = 1; diff --git a/src/ifs/wl_drm.rs b/src/ifs/wl_drm.rs index ab7d91ed..48e06907 100644 --- a/src/ifs/wl_drm.rs +++ b/src/ifs/wl_drm.rs @@ -1,19 +1,22 @@ -use crate::client::{Client, ClientError}; -use crate::drm::dma::{DmaBuf, DmaBufPlane}; -use crate::drm::INVALID_MODIFIER; -use crate::globals::{Global, GlobalName}; -use crate::ifs::wl_buffer::WlBuffer; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::render::RenderError; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::wl_drm::*; -use crate::wire::WlDrmId; -use bstr::ByteSlice; -use std::ffi::CString; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + video::{ + dma::{DmaBuf, DmaBufPlane}, + INVALID_MODIFIER, + }, + globals::{Global, GlobalName}, + ifs::wl_buffer::WlBuffer, + leaks::Tracker, + object::Object, + render::RenderError, + utils::buffd::{MsgParser, MsgParserError}, + wire::{wl_drm::*, WlDrmId}, + }, + bstr::ByteSlice, + std::{ffi::CString, rc::Rc}, + thiserror::Error, +}; const PRIME: u32 = 1; diff --git a/src/ifs/wl_output.rs b/src/ifs/wl_output.rs index f54572f6..e6b45578 100644 --- a/src/ifs/wl_output.rs +++ b/src/ifs/wl_output.rs @@ -1,23 +1,29 @@ -use crate::backend; -use crate::client::{Client, ClientError, ClientId}; -use crate::globals::{Global, GlobalName}; -use crate::ifs::zxdg_output_v1::ZxdgOutputV1; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::rect::Rect; -use crate::state::ConnectorData; -use crate::tree::OutputNode; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::utils::clonecell::CloneCell; -use crate::utils::copyhashmap::CopyHashMap; -use crate::wire::wl_output::*; -use crate::wire::{WlOutputId, ZxdgOutputV1Id}; -use ahash::AHashMap; -use std::cell::{Cell, RefCell}; -use std::collections::hash_map::Entry; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + backend, + client::{Client, ClientError, ClientId}, + globals::{Global, GlobalName}, + ifs::zxdg_output_v1::ZxdgOutputV1, + leaks::Tracker, + object::Object, + rect::Rect, + state::ConnectorData, + tree::OutputNode, + utils::{ + buffd::{MsgParser, MsgParserError}, + clonecell::CloneCell, + copyhashmap::CopyHashMap, + }, + wire::{wl_output::*, WlOutputId, ZxdgOutputV1Id}, + }, + ahash::AHashMap, + std::{ + cell::{Cell, RefCell}, + collections::hash_map::Entry, + rc::Rc, + }, + thiserror::Error, +}; const SP_UNKNOWN: i32 = 0; #[allow(dead_code)] diff --git a/src/ifs/wl_region.rs b/src/ifs/wl_region.rs index d6badcad..589912cd 100644 --- a/src/ifs/wl_region.rs +++ b/src/ifs/wl_region.rs @@ -1,14 +1,15 @@ -use crate::client::{Client, ClientError}; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::rect::{Rect, Region, RegionBuilder}; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::wl_region::*; -use crate::wire::WlRegionId; -use std::cell::RefCell; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + leaks::Tracker, + object::Object, + rect::{Rect, Region, RegionBuilder}, + utils::buffd::{MsgParser, MsgParserError}, + wire::{wl_region::*, WlRegionId}, + }, + std::{cell::RefCell, rc::Rc}, + thiserror::Error, +}; pub struct WlRegion { id: WlRegionId, diff --git a/src/ifs/wl_registry.rs b/src/ifs/wl_registry.rs index 495d7e87..fdfc1d9f 100644 --- a/src/ifs/wl_registry.rs +++ b/src/ifs/wl_registry.rs @@ -1,13 +1,15 @@ -use crate::client::Client; -use crate::globals::{Global, GlobalName, GlobalsError}; -use crate::leaks::Tracker; -use crate::object::{Interface, Object}; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::wl_registry::*; -use crate::wire::WlRegistryId; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::Client, + globals::{Global, GlobalName, GlobalsError}, + leaks::Tracker, + object::{Interface, Object}, + utils::buffd::{MsgParser, MsgParserError}, + wire::{wl_registry::*, WlRegistryId}, + }, + std::rc::Rc, + thiserror::Error, +}; pub struct WlRegistry { id: WlRegistryId, diff --git a/src/ifs/wl_seat.rs b/src/ifs/wl_seat.rs index 606c40c4..be69a086 100644 --- a/src/ifs/wl_seat.rs +++ b/src/ifs/wl_seat.rs @@ -5,53 +5,62 @@ pub mod wl_keyboard; pub mod wl_pointer; pub mod wl_touch; -use crate::async_engine::SpawnedFuture; -use crate::client::{Client, ClientError, ClientId}; -use crate::cursor::{Cursor, KnownCursor}; -use crate::fixed::Fixed; -use crate::globals::{Global, GlobalName}; -use crate::ifs::ipc; -use crate::ifs::ipc::wl_data_device::WlDataDevice; -use crate::ifs::ipc::wl_data_source::WlDataSource; -use crate::ifs::ipc::zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1; -use crate::ifs::ipc::zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1; -use crate::ifs::ipc::IpcError; -use crate::ifs::wl_seat::kb_owner::KbOwnerHolder; -use crate::ifs::wl_seat::pointer_owner::PointerOwnerHolder; -use crate::ifs::wl_seat::wl_keyboard::{WlKeyboard, WlKeyboardError, REPEAT_INFO_SINCE}; -use crate::ifs::wl_seat::wl_pointer::WlPointer; -use crate::ifs::wl_seat::wl_touch::WlTouch; -use crate::ifs::wl_surface::WlSurface; -use crate::leaks::Tracker; -use crate::object::{Object, ObjectId}; -use crate::state::State; -use crate::tree::toplevel::ToplevelNode; -use crate::tree::{ContainerSplit, FloatNode, FoundNode, Node, OutputNode}; -use crate::utils::asyncevent::AsyncEvent; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::utils::clonecell::CloneCell; -use crate::utils::copyhashmap::CopyHashMap; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::linkedlist::{LinkedList, LinkedNode}; -use crate::utils::numcell::NumCell; -use crate::utils::rc_eq::rc_eq; -use crate::wire::wl_seat::*; -use crate::wire::{ - WlDataDeviceId, WlKeyboardId, WlPointerId, WlSeatId, ZwpPrimarySelectionDeviceV1Id, -}; -use crate::xkbcommon::{XkbKeymap, XkbState}; -use ahash::{AHashMap, AHashSet}; pub use event_handling::NodeSeatState; -use jay_config::keyboard::mods::Modifiers; -use jay_config::Direction; -use std::cell::{Cell, RefCell}; -use std::collections::hash_map::Entry; -use std::mem; -use std::ops::DerefMut; -use std::rc::Rc; -use thiserror::Error; -use uapi::{c, Errno, OwnedFd}; +use { + crate::{ + async_engine::SpawnedFuture, + client::{Client, ClientError, ClientId}, + cursor::{Cursor, KnownCursor}, + fixed::Fixed, + globals::{Global, GlobalName}, + ifs::{ + ipc, + ipc::{ + wl_data_device::WlDataDevice, wl_data_source::WlDataSource, + zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1, + zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1, IpcError, + }, + wl_seat::{ + kb_owner::KbOwnerHolder, + pointer_owner::PointerOwnerHolder, + wl_keyboard::{WlKeyboard, WlKeyboardError, REPEAT_INFO_SINCE}, + wl_pointer::WlPointer, + wl_touch::WlTouch, + }, + wl_surface::WlSurface, + }, + leaks::Tracker, + object::{Object, ObjectId}, + state::State, + tree::{ContainerSplit, FloatNode, FoundNode, Node, OutputNode, ToplevelNode}, + utils::{ + asyncevent::AsyncEvent, + buffd::{MsgParser, MsgParserError}, + clonecell::CloneCell, + copyhashmap::CopyHashMap, + errorfmt::ErrorFmt, + linkedlist::{LinkedList, LinkedNode}, + numcell::NumCell, + rc_eq::rc_eq, + }, + wire::{ + wl_seat::*, WlDataDeviceId, WlKeyboardId, WlPointerId, WlSeatId, + ZwpPrimarySelectionDeviceV1Id, + }, + xkbcommon::{XkbKeymap, XkbState}, + }, + ahash::{AHashMap, AHashSet}, + jay_config::{keyboard::mods::Modifiers, Direction}, + std::{ + cell::{Cell, RefCell}, + collections::hash_map::Entry, + mem, + ops::DerefMut, + rc::Rc, + }, + thiserror::Error, + uapi::{c, Errno, OwnedFd}, +}; const POINTER: u32 = 1; const KEYBOARD: u32 = 2; diff --git a/src/ifs/wl_seat/event_handling.rs b/src/ifs/wl_seat/event_handling.rs index d7dd4184..35615ccd 100644 --- a/src/ifs/wl_seat/event_handling.rs +++ b/src/ifs/wl_seat/event_handling.rs @@ -1,27 +1,31 @@ -use crate::backend::{ConnectorId, InputEvent, KeyState, ScrollAxis}; -use crate::client::{Client, ClientId}; -use crate::fixed::Fixed; -use crate::ifs::ipc; -use crate::ifs::ipc::wl_data_device::WlDataDevice; -use crate::ifs::ipc::zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1; -use crate::ifs::wl_seat::wl_keyboard::WlKeyboard; -use crate::ifs::wl_seat::wl_pointer::{WlPointer, POINTER_FRAME_SINCE_VERSION}; -use crate::ifs::wl_seat::{wl_keyboard, wl_pointer, Dnd, SeatId, WlSeat, WlSeatGlobal}; -use crate::ifs::wl_surface::xdg_surface::xdg_popup::XdgPopup; -use crate::ifs::wl_surface::WlSurface; -use crate::object::ObjectId; -use crate::tree::toplevel::ToplevelNode; -use crate::tree::{FloatNode, Node, OutputNode}; -use crate::utils::clonecell::CloneCell; -use crate::utils::smallmap::SmallMap; -use crate::wire::WlDataOfferId; -use crate::xkbcommon::{ModifierState, XKB_KEY_DOWN, XKB_KEY_UP}; -use jay_config::keyboard::mods::Modifiers; -use jay_config::keyboard::syms::KeySym; -use jay_config::keyboard::ModifiedKeySym; -use smallvec::SmallVec; -use std::ops::Deref; -use std::rc::Rc; +use { + crate::{ + backend::{ConnectorId, InputEvent, KeyState, ScrollAxis}, + client::{Client, ClientId}, + fixed::Fixed, + ifs::{ + ipc, + ipc::{ + wl_data_device::WlDataDevice, + zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1, + }, + wl_seat::{ + wl_keyboard::{self, WlKeyboard}, + wl_pointer::{self, WlPointer, POINTER_FRAME_SINCE_VERSION}, + Dnd, SeatId, WlSeat, WlSeatGlobal, + }, + wl_surface::{xdg_surface::xdg_popup::XdgPopup, WlSurface}, + }, + object::ObjectId, + tree::{FloatNode, Node, OutputNode, ToplevelNode}, + utils::{clonecell::CloneCell, smallmap::SmallMap}, + wire::WlDataOfferId, + xkbcommon::{ModifierState, XKB_KEY_DOWN, XKB_KEY_UP}, + }, + jay_config::keyboard::{mods::Modifiers, syms::KeySym, ModifiedKeySym}, + smallvec::SmallVec, + std::{ops::Deref, rc::Rc}, +}; #[derive(Default)] pub struct NodeSeatState { @@ -126,23 +130,47 @@ impl WlSeatGlobal { mut x: Fixed, mut y: Fixed, ) { - let output = match self.state.connectors.get(&connector) { + let output = match self.state.outputs.get(&connector) { Some(o) => o, _ => return, }; - let node = match output.node.get() { - Some(n) => n, - _ => return, - }; - let pos = node.global.pos.get(); + let pos = output.node.global.pos.get(); x += Fixed::from_int(pos.x1()); y += Fixed::from_int(pos.y1()); self.set_new_position(x, y); } fn motion_event(self: &Rc, dx: Fixed, dy: Fixed) { - let (x, y) = self.pos.get(); - self.set_new_position(x + dx, y + dy); + let (mut x, mut y) = self.pos.get(); + x += dx; + y += dy; + let output = self.output.get(); + let pos = output.global.pos.get(); + let mut x_int = x.round_down(); + let mut y_int = y.round_down(); + if !pos.contains(x_int, y_int) { + 'warp: { + let outputs = self.state.outputs.lock(); + for output in outputs.values() { + if output.node.global.pos.get().contains(x_int, y_int) { + break 'warp; + } + } + if x_int < pos.x1() { + x_int = pos.x1(); + } else if x_int >= pos.x2() { + x_int = pos.x2() - 1; + } + if y_int < pos.y1() { + y_int = pos.y1(); + } else if y_int >= pos.y2() { + y_int = pos.y2() - 1; + } + x = x.apply_fract(x_int); + y = y.apply_fract(y_int); + } + } + self.set_new_position(x, y); } fn key_event(&self, key: u32, state: KeyState) { @@ -201,8 +229,10 @@ impl WlSeatGlobal { } pub fn last_tiled_keyboard_toplevel(&self, new: &dyn Node) -> Option> { - let output = self.output.get(); - let workspace = output.workspace.get().unwrap(); + let workspace = match self.output.get().workspace.get() { + Some(ws) => ws, + _ => return None, + }; let is_container = new.is_container(); for tl in self.toplevel_focus_history.rev_iter() { match tl.as_node().get_workspace() { @@ -448,10 +478,6 @@ impl WlSeatGlobal { self.surface_pointer_event(0, n, |p| p.send_leave(serial, n.id)); self.surface_pointer_frame(n); } - - pub fn leave_output(&self) { - self.output.set(self.state.dummy_output.get().unwrap()); - } } // Unfocus callbacks diff --git a/src/ifs/wl_seat/kb_owner.rs b/src/ifs/wl_seat/kb_owner.rs index 5b4a9f6b..06d646d1 100644 --- a/src/ifs/wl_seat/kb_owner.rs +++ b/src/ifs/wl_seat/kb_owner.rs @@ -1,8 +1,11 @@ -use crate::ifs::wl_seat::WlSeatGlobal; -use crate::tree::{Node, OutputNode}; -use crate::utils::clonecell::CloneCell; -use std::ops::Deref; -use std::rc::Rc; +use { + crate::{ + ifs::wl_seat::WlSeatGlobal, + tree::{Node, OutputNode}, + utils::clonecell::CloneCell, + }, + std::{ops::Deref, rc::Rc}, +}; pub struct KbOwnerHolder { default: Rc, diff --git a/src/ifs/wl_seat/pointer_owner.rs b/src/ifs/wl_seat/pointer_owner.rs index baef9db6..2585f9b4 100644 --- a/src/ifs/wl_seat/pointer_owner.rs +++ b/src/ifs/wl_seat/pointer_owner.rs @@ -1,15 +1,18 @@ -use crate::backend::{KeyState, ScrollAxis}; -use crate::fixed::Fixed; -use crate::ifs::ipc; -use crate::ifs::ipc::wl_data_device::WlDataDevice; -use crate::ifs::ipc::wl_data_source::WlDataSource; -use crate::ifs::wl_seat::{Dnd, DroppedDnd, WlSeatError, WlSeatGlobal}; -use crate::ifs::wl_surface::WlSurface; -use crate::tree::{FoundNode, Node}; -use crate::utils::clonecell::CloneCell; -use crate::utils::smallmap::SmallMap; -use std::cell::Cell; -use std::rc::Rc; +use { + crate::{ + backend::{KeyState, ScrollAxis}, + fixed::Fixed, + ifs::{ + ipc, + ipc::{wl_data_device::WlDataDevice, wl_data_source::WlDataSource}, + wl_seat::{Dnd, DroppedDnd, WlSeatError, WlSeatGlobal}, + wl_surface::WlSurface, + }, + tree::{FoundNode, Node}, + utils::{clonecell::CloneCell, smallmap::SmallMap}, + }, + std::{cell::Cell, rc::Rc}, +}; pub struct PointerOwnerHolder { default: Rc, diff --git a/src/ifs/wl_seat/wl_keyboard.rs b/src/ifs/wl_seat/wl_keyboard.rs index 55af17bd..250cf14d 100644 --- a/src/ifs/wl_seat/wl_keyboard.rs +++ b/src/ifs/wl_seat/wl_keyboard.rs @@ -1,14 +1,16 @@ -use crate::client::ClientError; -use crate::ifs::wl_seat::WlSeat; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::wl_keyboard::*; -use crate::wire::{WlKeyboardId, WlSurfaceId}; -use std::rc::Rc; -use thiserror::Error; -use uapi::OwnedFd; +use { + crate::{ + client::ClientError, + ifs::wl_seat::WlSeat, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{wl_keyboard::*, WlKeyboardId, WlSurfaceId}, + }, + std::rc::Rc, + thiserror::Error, + uapi::OwnedFd, +}; pub const REPEAT_INFO_SINCE: u32 = 4; diff --git a/src/ifs/wl_seat/wl_pointer.rs b/src/ifs/wl_seat/wl_pointer.rs index ee5ef2a6..1add4e57 100644 --- a/src/ifs/wl_seat/wl_pointer.rs +++ b/src/ifs/wl_seat/wl_pointer.rs @@ -1,16 +1,17 @@ -use crate::client::ClientError; -use crate::cursor::Cursor; -use crate::fixed::Fixed; -use crate::ifs::wl_seat::WlSeat; -use crate::ifs::wl_surface::WlSurfaceError; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::wl_pointer::*; -use crate::wire::{WlPointerId, WlSurfaceId}; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::ClientError, + cursor::Cursor, + fixed::Fixed, + ifs::{wl_seat::WlSeat, wl_surface::WlSurfaceError}, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{wl_pointer::*, WlPointerId, WlSurfaceId}, + }, + std::rc::Rc, + thiserror::Error, +}; #[allow(dead_code)] const ROLE: u32 = 0; diff --git a/src/ifs/wl_seat/wl_touch.rs b/src/ifs/wl_seat/wl_touch.rs index ffeb04fb..4d864106 100644 --- a/src/ifs/wl_seat/wl_touch.rs +++ b/src/ifs/wl_seat/wl_touch.rs @@ -1,13 +1,15 @@ -use crate::client::ClientError; -use crate::ifs::wl_seat::WlSeat; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::wl_touch::*; -use crate::wire::WlTouchId; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::ClientError, + ifs::wl_seat::WlSeat, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{wl_touch::*, WlTouchId}, + }, + std::rc::Rc, + thiserror::Error, +}; #[allow(dead_code)] const DOWN: u32 = 0; diff --git a/src/ifs/wl_shm.rs b/src/ifs/wl_shm.rs index 1bdd24e8..a2f44c61 100644 --- a/src/ifs/wl_shm.rs +++ b/src/ifs/wl_shm.rs @@ -1,15 +1,17 @@ -use crate::client::{Client, ClientError}; -use crate::format::FORMATS; -use crate::globals::{Global, GlobalName}; -use crate::ifs::wl_shm_pool::{WlShmPool, WlShmPoolError}; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::wl_shm::*; -use crate::wire::WlShmId; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + format::FORMATS, + globals::{Global, GlobalName}, + ifs::wl_shm_pool::{WlShmPool, WlShmPoolError}, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{wl_shm::*, WlShmId}, + }, + std::rc::Rc, + thiserror::Error, +}; pub struct WlShmGlobal { name: GlobalName, diff --git a/src/ifs/wl_shm_pool.rs b/src/ifs/wl_shm_pool.rs index 7e24bf8e..29cf6862 100644 --- a/src/ifs/wl_shm_pool.rs +++ b/src/ifs/wl_shm_pool.rs @@ -1,17 +1,21 @@ -use crate::client::{Client, ClientError}; -use crate::clientmem::{ClientMem, ClientMemError}; -use crate::format::{formats, map_wayland_format_id}; -use crate::ifs::wl_buffer::{WlBuffer, WlBufferError}; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::utils::clonecell::CloneCell; -use crate::wire::wl_shm_pool::*; -use crate::wire::WlShmPoolId; -use std::rc::Rc; -use thiserror::Error; -use uapi::OwnedFd; +use { + crate::{ + client::{Client, ClientError}, + clientmem::{ClientMem, ClientMemError}, + format::{formats, map_wayland_format_id}, + ifs::wl_buffer::{WlBuffer, WlBufferError}, + leaks::Tracker, + object::Object, + utils::{ + buffd::{MsgParser, MsgParserError}, + clonecell::CloneCell, + }, + wire::{wl_shm_pool::*, WlShmPoolId}, + }, + std::rc::Rc, + thiserror::Error, + uapi::OwnedFd, +}; pub struct WlShmPool { id: WlShmPoolId, diff --git a/src/ifs/wl_subcompositor.rs b/src/ifs/wl_subcompositor.rs index b5468242..e7548d0f 100644 --- a/src/ifs/wl_subcompositor.rs +++ b/src/ifs/wl_subcompositor.rs @@ -1,14 +1,16 @@ -use crate::client::{Client, ClientError}; -use crate::globals::{Global, GlobalName}; -use crate::ifs::wl_surface::wl_subsurface::{WlSubsurface, WlSubsurfaceError}; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::wl_subcompositor::*; -use crate::wire::WlSubcompositorId; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + globals::{Global, GlobalName}, + ifs::wl_surface::wl_subsurface::{WlSubsurface, WlSubsurfaceError}, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{wl_subcompositor::*, WlSubcompositorId}, + }, + std::rc::Rc, + thiserror::Error, +}; #[allow(dead_code)] const BAD_SURFACE: u32 = 0; diff --git a/src/ifs/wl_surface.rs b/src/ifs/wl_surface.rs index fc453a3f..9c2e0671 100644 --- a/src/ifs/wl_surface.rs +++ b/src/ifs/wl_surface.rs @@ -4,39 +4,49 @@ pub mod xdg_surface; pub mod xwindow; pub mod zwlr_layer_surface_v1; -use crate::backend::{KeyState, ScrollAxis}; -use crate::client::{Client, ClientError, RequestParser}; -use crate::fixed::Fixed; -use crate::ifs::wl_buffer::WlBuffer; -use crate::ifs::wl_callback::WlCallback; -use crate::ifs::wl_seat::{Dnd, NodeSeatState, SeatId, WlSeatGlobal}; -use crate::ifs::wl_surface::cursor::CursorSurface; -use crate::ifs::wl_surface::wl_subsurface::WlSubsurface; -use crate::ifs::wl_surface::xdg_surface::XdgSurfaceError; -use crate::ifs::wl_surface::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1Error; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::rect::{Rect, Region}; -use crate::render::Renderer; -use crate::tree::toplevel::ToplevelNode; -use crate::tree::walker::NodeVisitor; -use crate::tree::{ContainerNode, ContainerSplit, Node, NodeId, WorkspaceNode}; -use crate::utils::buffd::{MsgParser, MsgParserError}; -use crate::utils::clonecell::CloneCell; -use crate::utils::linkedlist::LinkedList; -use crate::utils::numcell::NumCell; -use crate::utils::smallmap::SmallMap; -use crate::wire::wl_surface::*; -use crate::wire::{WlOutputId, WlSurfaceId}; -use crate::xkbcommon::ModifierState; -use ahash::AHashMap; -use jay_config::Direction; -use std::cell::{Cell, RefCell}; -use std::fmt::{Debug, Formatter}; -use std::mem; -use std::ops::{Deref, DerefMut}; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + backend::{KeyState, ScrollAxis}, + client::{Client, ClientError, RequestParser}, + fixed::Fixed, + ifs::{ + wl_buffer::WlBuffer, + wl_callback::WlCallback, + wl_seat::{Dnd, NodeSeatState, SeatId, WlSeatGlobal}, + wl_surface::{ + cursor::CursorSurface, wl_subsurface::WlSubsurface, xdg_surface::XdgSurfaceError, + zwlr_layer_surface_v1::ZwlrLayerSurfaceV1Error, + }, + }, + leaks::Tracker, + object::Object, + rect::{Rect, Region}, + render::Renderer, + tree::{ + ContainerNode, ContainerSplit, FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, + ToplevelNode, WorkspaceNode, + }, + utils::{ + buffd::{MsgParser, MsgParserError}, + clonecell::CloneCell, + linkedlist::LinkedList, + numcell::NumCell, + smallmap::SmallMap, + }, + wire::{wl_surface::*, WlOutputId, WlSurfaceId}, + xkbcommon::ModifierState, + }, + ahash::AHashMap, + jay_config::Direction, + std::{ + cell::{Cell, RefCell}, + fmt::{Debug, Formatter}, + mem, + ops::{Deref, DerefMut}, + rc::Rc, + }, + thiserror::Error, +}; #[allow(dead_code)] const INVALID_SCALE: u32 = 0; @@ -365,7 +375,11 @@ impl WlSurface { } *children = None; } - self.buffer.set(None); + if let Some(buffer) = self.buffer.set(None) { + if !buffer.destroyed() { + buffer.send_release(); + } + } self.frame_requests.borrow_mut().clear(); self.toplevel.set(None); self.client.remove_obj(self)?; @@ -558,6 +572,16 @@ impl WlSurface { } None } + + fn find_tree_at_(self: &Rc, x: i32, y: i32, tree: &mut Vec) -> FindTreeResult { + match self.find_surface_at(x, y) { + Some((node, x, y)) => { + tree.push(FoundNode { node, x, y }); + FindTreeResult::AcceptsInput + } + _ => FindTreeResult::Other, + } + } } object_base! { diff --git a/src/ifs/wl_surface/cursor.rs b/src/ifs/wl_surface/cursor.rs index 68e0fada..f9adf64d 100644 --- a/src/ifs/wl_surface/cursor.rs +++ b/src/ifs/wl_surface/cursor.rs @@ -1,11 +1,13 @@ -use crate::cursor::Cursor; -use crate::ifs::wl_seat::WlSeatGlobal; -use crate::ifs::wl_surface::WlSurface; -use crate::leaks::Tracker; -use crate::rect::Rect; -use crate::render::Renderer; -use std::cell::Cell; -use std::rc::Rc; +use { + crate::{ + cursor::Cursor, + ifs::{wl_seat::WlSeatGlobal, wl_surface::WlSurface}, + leaks::Tracker, + rect::Rect, + render::Renderer, + }, + std::{cell::Cell, rc::Rc}, +}; pub struct CursorSurface { seat: Rc, diff --git a/src/ifs/wl_surface/wl_subsurface.rs b/src/ifs/wl_surface/wl_subsurface.rs index 28968f63..4ebf881f 100644 --- a/src/ifs/wl_surface/wl_subsurface.rs +++ b/src/ifs/wl_surface/wl_subsurface.rs @@ -1,21 +1,27 @@ -use crate::client::ClientError; -use crate::ifs::wl_surface::{ - CommitAction, CommitContext, StackElement, SurfaceExt, SurfaceRole, WlSurface, WlSurfaceError, - WlSurfaceId, +use { + crate::{ + client::ClientError, + ifs::wl_surface::{ + CommitAction, CommitContext, StackElement, SurfaceExt, SurfaceRole, WlSurface, + WlSurfaceError, WlSurfaceId, + }, + leaks::Tracker, + object::Object, + rect::Rect, + utils::{ + buffd::{MsgParser, MsgParserError}, + linkedlist::LinkedNode, + numcell::NumCell, + }, + wire::{wl_subsurface::*, WlSubsurfaceId}, + }, + std::{ + cell::{Cell, RefCell}, + ops::Deref, + rc::Rc, + }, + thiserror::Error, }; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::rect::Rect; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::utils::linkedlist::LinkedNode; -use crate::utils::numcell::NumCell; -use crate::wire::wl_subsurface::*; -use crate::wire::WlSubsurfaceId; -use std::cell::{Cell, RefCell}; -use std::ops::Deref; -use std::rc::Rc; -use thiserror::Error; #[allow(dead_code)] const BAD_SURFACE: u32 = 0; diff --git a/src/ifs/wl_surface/xdg_surface.rs b/src/ifs/wl_surface/xdg_surface.rs index 5705a0be..7ac86860 100644 --- a/src/ifs/wl_surface/xdg_surface.rs +++ b/src/ifs/wl_surface/xdg_surface.rs @@ -1,29 +1,35 @@ pub mod xdg_popup; pub mod xdg_toplevel; -use crate::client::ClientError; -use crate::ifs::wl_seat::NodeSeatState; -use crate::ifs::wl_surface::xdg_surface::xdg_popup::{XdgPopup, XdgPopupError}; -use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel; -use crate::ifs::wl_surface::{ - CommitAction, CommitContext, SurfaceExt, SurfaceRole, WlSurface, WlSurfaceError, +use { + crate::{ + client::ClientError, + ifs::{ + wl_seat::NodeSeatState, + wl_surface::{ + xdg_surface::{ + xdg_popup::{XdgPopup, XdgPopupError}, + xdg_toplevel::XdgToplevel, + }, + CommitAction, CommitContext, SurfaceExt, SurfaceRole, WlSurface, WlSurfaceError, + }, + xdg_wm_base::XdgWmBase, + }, + leaks::Tracker, + object::Object, + rect::Rect, + tree::{FindTreeResult, FoundNode, Node, WorkspaceNode}, + utils::{ + buffd::{MsgParser, MsgParserError}, + clonecell::CloneCell, + copyhashmap::CopyHashMap, + numcell::NumCell, + }, + wire::{xdg_surface::*, WlSurfaceId, XdgPopupId, XdgSurfaceId}, + }, + std::{cell::Cell, fmt::Debug, rc::Rc}, + thiserror::Error, }; -use crate::ifs::xdg_wm_base::XdgWmBase; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::rect::Rect; -use crate::tree::{FindTreeResult, FoundNode, Node, WorkspaceNode}; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::utils::clonecell::CloneCell; -use crate::utils::copyhashmap::CopyHashMap; -use crate::utils::numcell::NumCell; -use crate::wire::xdg_surface::*; -use crate::wire::{WlSurfaceId, XdgPopupId, XdgSurfaceId}; -use std::cell::Cell; -use std::fmt::Debug; -use std::rc::Rc; -use thiserror::Error; #[allow(dead_code)] const NOT_CONSTRUCTED: u32 = 1; @@ -284,13 +290,7 @@ impl XdgSurface { x = xt; y = yt; } - match self.surface.find_surface_at(x, y) { - Some((node, x, y)) => { - tree.push(FoundNode { node, x, y }); - FindTreeResult::AcceptsInput - } - _ => FindTreeResult::Other, - } + self.surface.find_tree_at_(x, y, tree) } fn update_popup_positions(&self) { diff --git a/src/ifs/wl_surface/xdg_surface/xdg_popup.rs b/src/ifs/wl_surface/xdg_surface/xdg_popup.rs index 2fbe1129..a84a5fd0 100644 --- a/src/ifs/wl_surface/xdg_surface/xdg_popup.rs +++ b/src/ifs/wl_surface/xdg_surface/xdg_popup.rs @@ -1,25 +1,32 @@ -use crate::client::{Client, ClientError}; -use crate::cursor::KnownCursor; -use crate::fixed::Fixed; -use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal}; -use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceError, XdgSurfaceExt}; -use crate::ifs::xdg_positioner::{XdgPositioned, XdgPositioner, CA}; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::rect::Rect; -use crate::render::Renderer; -use crate::tree::walker::NodeVisitor; -use crate::tree::{FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode}; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::utils::clonecell::CloneCell; -use crate::utils::linkedlist::LinkedNode; -use crate::wire::xdg_popup::*; -use crate::wire::XdgPopupId; -use std::cell::{Cell, RefCell}; -use std::fmt::{Debug, Formatter}; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + cursor::KnownCursor, + fixed::Fixed, + ifs::{ + wl_seat::{NodeSeatState, WlSeatGlobal}, + wl_surface::xdg_surface::{XdgSurface, XdgSurfaceError, XdgSurfaceExt}, + xdg_positioner::{XdgPositioned, XdgPositioner, CA}, + }, + leaks::Tracker, + object::Object, + rect::Rect, + render::Renderer, + tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, WorkspaceNode}, + utils::{ + buffd::{MsgParser, MsgParserError}, + clonecell::CloneCell, + linkedlist::LinkedNode, + }, + wire::{xdg_popup::*, XdgPopupId}, + }, + std::{ + cell::{Cell, RefCell}, + fmt::{Debug, Formatter}, + rc::Rc, + }, + thiserror::Error, +}; #[allow(dead_code)] const INVALID_GRAB: u32 = 1; diff --git a/src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs b/src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs index 36c5f871..0ff7f99a 100644 --- a/src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs +++ b/src/ifs/wl_surface/xdg_surface/xdg_toplevel.rs @@ -1,33 +1,43 @@ -use crate::bugs; -use crate::bugs::Bugs; -use crate::client::{Client, ClientError}; -use crate::cursor::KnownCursor; -use crate::fixed::Fixed; -use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal}; -use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceError, XdgSurfaceExt}; -use crate::ifs::wl_surface::WlSurface; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::rect::Rect; -use crate::render::Renderer; -use crate::tree::toplevel::{ToplevelData, ToplevelNode}; -use crate::tree::walker::NodeVisitor; -use crate::tree::FindTreeResult; -use crate::tree::{FoundNode, Node, NodeId, ToplevelNodeId, WorkspaceNode}; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::utils::clonecell::CloneCell; -use crate::wire::xdg_toplevel::*; -use crate::wire::XdgToplevelId; -use ahash::{AHashMap, AHashSet}; -use jay_config::Direction; -use num_derive::FromPrimitive; -use std::cell::{Cell, RefCell}; -use std::fmt::{Debug, Formatter}; -use std::mem; -use std::ops::Deref; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + bugs, + bugs::Bugs, + client::{Client, ClientError}, + cursor::KnownCursor, + fixed::Fixed, + ifs::{ + wl_seat::{NodeSeatState, WlSeatGlobal}, + wl_surface::{ + xdg_surface::{XdgSurface, XdgSurfaceError, XdgSurfaceExt}, + WlSurface, + }, + }, + leaks::Tracker, + object::Object, + rect::Rect, + render::Renderer, + tree::{ + FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, ToplevelData, ToplevelNode, + ToplevelNodeId, WorkspaceNode, + }, + utils::{ + buffd::{MsgParser, MsgParserError}, + clonecell::CloneCell, + }, + wire::{xdg_toplevel::*, XdgToplevelId}, + }, + ahash::{AHashMap, AHashSet}, + jay_config::Direction, + num_derive::FromPrimitive, + std::{ + cell::{Cell, RefCell}, + fmt::{Debug, Formatter}, + mem, + ops::Deref, + rc::Rc, + }, + thiserror::Error, +}; #[derive(Copy, Clone, Debug, FromPrimitive)] pub enum ResizeEdge { diff --git a/src/ifs/wl_surface/xwindow.rs b/src/ifs/wl_surface/xwindow.rs index 2660104c..752cf0f9 100644 --- a/src/ifs/wl_surface/xwindow.rs +++ b/src/ifs/wl_surface/xwindow.rs @@ -1,28 +1,36 @@ -use crate::client::Client; -use crate::cursor::KnownCursor; -use crate::fixed::Fixed; -use crate::ifs::wl_seat::{NodeSeatState, SeatId, WlSeatGlobal}; -use crate::ifs::wl_surface::{SurfaceExt, SurfaceRole, WlSurface, WlSurfaceError}; -use crate::rect::Rect; -use crate::render::Renderer; -use crate::state::State; -use crate::tree::toplevel::{ToplevelData, ToplevelNode}; -use crate::tree::walker::NodeVisitor; -use crate::tree::{FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode}; -use crate::utils::clonecell::CloneCell; -use crate::utils::copyhashmap::CopyHashMap; -use crate::utils::linkedlist::LinkedNode; -use crate::utils::queue::AsyncQueue; -use crate::utils::smallmap::SmallMap; -use crate::wire::WlSurfaceId; -use crate::wire_xcon::CreateNotify; -use crate::xwayland::XWaylandEvent; -use bstr::BString; -use jay_config::Direction; -use std::cell::{Cell, RefCell}; -use std::ops::{Deref, Not}; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::Client, + cursor::KnownCursor, + fixed::Fixed, + ifs::{ + wl_seat::{NodeSeatState, SeatId, WlSeatGlobal}, + wl_surface::{SurfaceExt, SurfaceRole, WlSurface, WlSurfaceError}, + }, + rect::Rect, + render::Renderer, + state::State, + tree::{ + FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, ToplevelData, ToplevelNode, + WorkspaceNode, + }, + utils::{ + clonecell::CloneCell, copyhashmap::CopyHashMap, linkedlist::LinkedNode, + queue::AsyncQueue, smallmap::SmallMap, + }, + wire::WlSurfaceId, + wire_xcon::CreateNotify, + xwayland::XWaylandEvent, + }, + bstr::BString, + jay_config::Direction, + std::{ + cell::{Cell, RefCell}, + ops::{Deref, Not}, + rc::Rc, + }, + thiserror::Error, +}; #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum XInputModel { @@ -275,20 +283,16 @@ impl Xwindow { self.data.state.tree_changed(); } Change::Map if self.data.info.wants_floating.get() => { - let ws = self - .data - .state - .root - .outputs - .lock() - .iter() - .next() - .unwrap() - .1 - .workspace - .get() - .unwrap(); - // todo + let ws = match self.data.state.root.outputs.lock().values().cloned().next() { + Some(output) => output.ensure_workspace(), + _ => self + .data + .state + .dummy_output + .get() + .unwrap() + .ensure_workspace(), + }; let ext = self.data.info.extents.get(); self.data .state diff --git a/src/ifs/wl_surface/zwlr_layer_surface_v1.rs b/src/ifs/wl_surface/zwlr_layer_surface_v1.rs index 10f5fa16..37dd92cd 100644 --- a/src/ifs/wl_surface/zwlr_layer_surface_v1.rs +++ b/src/ifs/wl_surface/zwlr_layer_surface_v1.rs @@ -1,26 +1,29 @@ -use crate::client::{Client, ClientError}; -use crate::ifs::wl_seat::NodeSeatState; -use crate::ifs::wl_surface::{ - CommitAction, CommitContext, SurfaceExt, SurfaceRole, WlSurface, WlSurfaceError, +use { + crate::{ + client::{Client, ClientError}, + ifs::{ + wl_seat::NodeSeatState, + wl_surface::{ + CommitAction, CommitContext, SurfaceExt, SurfaceRole, WlSurface, WlSurfaceError, + }, + zwlr_layer_shell_v1::{ZwlrLayerShellV1, OVERLAY}, + }, + leaks::Tracker, + object::Object, + rect::Rect, + render::Renderer, + tree::{FindTreeResult, FoundNode, Node, NodeId, NodeVisitor, OutputNode}, + utils::{ + bitflags::BitflagsExt, + buffd::{MsgParser, MsgParserError}, + linkedlist::LinkedNode, + numcell::NumCell, + }, + wire::{zwlr_layer_surface_v1::*, WlSurfaceId, ZwlrLayerSurfaceV1Id}, + }, + std::{cell::Cell, ops::Deref, rc::Rc}, + thiserror::Error, }; -use crate::ifs::zwlr_layer_shell_v1::{ZwlrLayerShellV1, OVERLAY}; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::rect::Rect; -use crate::render::Renderer; -use crate::tree::walker::NodeVisitor; -use crate::tree::{FindTreeResult, FoundNode, Node, NodeId, OutputNode}; -use crate::utils::bitflags::BitflagsExt; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::utils::linkedlist::LinkedNode; -use crate::utils::numcell::NumCell; -use crate::wire::zwlr_layer_surface_v1::*; -use crate::wire::{WlSurfaceId, ZwlrLayerSurfaceV1Id}; -use std::cell::Cell; -use std::ops::Deref; -use std::rc::Rc; -use thiserror::Error; const KI_NONE: u32 = 0; #[allow(dead_code)] @@ -65,6 +68,7 @@ struct Pending { margin: Cell>, keyboard_interactivity: Cell>, layer: Cell>, + any: Cell, } impl ZwlrLayerSurfaceV1 { @@ -132,6 +136,7 @@ impl ZwlrLayerSurfaceV1 { self.pending .size .set(Some((req.width as _, req.height as _))); + self.pending.any.set(true); Ok(()) } @@ -141,12 +146,14 @@ impl ZwlrLayerSurfaceV1 { return Err(SetAnchorError::UnknownAnchor(req.anchor)); } self.pending.anchor.set(Some(req.anchor)); + self.pending.any.set(true); Ok(()) } fn set_exclusive_zone(&self, parser: MsgParser<'_, '_>) -> Result<(), SetExclusiveZoneError> { let req: SetExclusiveZone = self.client.parse(self, parser)?; self.pending.exclusive_zone.set(Some(req.zone)); + self.pending.any.set(true); Ok(()) } @@ -155,6 +162,7 @@ impl ZwlrLayerSurfaceV1 { self.pending .margin .set(Some((req.top, req.right, req.bottom, req.left))); + self.pending.any.set(true); Ok(()) } @@ -171,6 +179,7 @@ impl ZwlrLayerSurfaceV1 { self.pending .keyboard_interactivity .set(Some(req.keyboard_interactivity)); + self.pending.any.set(true); Ok(()) } @@ -199,11 +208,12 @@ impl ZwlrLayerSurfaceV1 { return Err(SetLayerError::UnknownLayer(req.layer)); } self.pending.layer.set(Some(req.layer)); + self.pending.any.set(true); Ok(()) } fn pre_commit(&self) -> Result<(), ZwlrLayerSurfaceV1Error> { - let mut send_configure = false; + let mut send_configure = self.pending.any.replace(false); if let Some(size) = self.pending.size.take() { self.size.set(size); } @@ -370,7 +380,7 @@ impl Node for ZwlrLayerSurfaceV1 { x, y, }); - self.surface.find_tree_at(x, y, tree) + self.surface.find_tree_at_(x, y, tree) } fn render(&self, renderer: &mut Renderer, x: i32, y: i32) { diff --git a/src/ifs/xdg_positioner.rs b/src/ifs/xdg_positioner.rs index 59277272..6f0a457c 100644 --- a/src/ifs/xdg_positioner.rs +++ b/src/ifs/xdg_positioner.rs @@ -1,16 +1,17 @@ -use crate::client::{Client, ClientError}; -use crate::ifs::xdg_wm_base::XdgWmBase; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::rect::Rect; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::xdg_positioner::*; -use crate::wire::XdgPositionerId; -use bitflags::bitflags; -use std::cell::RefCell; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + ifs::xdg_wm_base::XdgWmBase, + leaks::Tracker, + object::Object, + rect::Rect, + utils::buffd::{MsgParser, MsgParserError}, + wire::{xdg_positioner::*, XdgPositionerId}, + }, + bitflags::bitflags, + std::{cell::RefCell, rc::Rc}, + thiserror::Error, +}; const INVALID_INPUT: u32 = 0; diff --git a/src/ifs/xdg_wm_base.rs b/src/ifs/xdg_wm_base.rs index 4e541e90..53b6c317 100644 --- a/src/ifs/xdg_wm_base.rs +++ b/src/ifs/xdg_wm_base.rs @@ -1,16 +1,22 @@ -use crate::client::{Client, ClientError}; -use crate::globals::{Global, GlobalName}; -use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceError}; -use crate::ifs::xdg_positioner::XdgPositioner; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::utils::copyhashmap::CopyHashMap; -use crate::wire::xdg_wm_base::*; -use crate::wire::{XdgSurfaceId, XdgWmBaseId}; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + globals::{Global, GlobalName}, + ifs::{ + wl_surface::xdg_surface::{XdgSurface, XdgSurfaceError}, + xdg_positioner::XdgPositioner, + }, + leaks::Tracker, + object::Object, + utils::{ + buffd::{MsgParser, MsgParserError}, + copyhashmap::CopyHashMap, + }, + wire::{xdg_wm_base::*, XdgSurfaceId, XdgWmBaseId}, + }, + std::rc::Rc, + thiserror::Error, +}; #[allow(dead_code)] const ROLE: u32 = 0; diff --git a/src/ifs/zwlr_layer_shell_v1.rs b/src/ifs/zwlr_layer_shell_v1.rs index cf5efb36..89e4337b 100644 --- a/src/ifs/zwlr_layer_shell_v1.rs +++ b/src/ifs/zwlr_layer_shell_v1.rs @@ -1,20 +1,21 @@ -use crate::client::{Client, ClientError}; -use crate::globals::{Global, GlobalName}; -use crate::ifs::wl_surface::zwlr_layer_surface_v1::{ZwlrLayerSurfaceV1, ZwlrLayerSurfaceV1Error}; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::zwlr_layer_shell_v1::*; -use crate::wire::ZwlrLayerShellV1Id; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + globals::{Global, GlobalName}, + ifs::wl_surface::zwlr_layer_surface_v1::{ZwlrLayerSurfaceV1, ZwlrLayerSurfaceV1Error}, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{zwlr_layer_shell_v1::*, ZwlrLayerShellV1Id}, + }, + std::rc::Rc, + thiserror::Error, +}; #[allow(dead_code)] pub const BACKGROUND: u32 = 0; #[allow(dead_code)] pub const BOTTOM: u32 = 1; -#[allow(dead_code)] pub const TOP: u32 = 2; pub const OVERLAY: u32 = 3; @@ -75,16 +76,13 @@ impl ZwlrLayerShellV1 { break 'get_output output; } } - let outputs = self.client.state.connectors.lock(); - for output in outputs.values() { - if let Some(node) = output.node.get() { - break 'get_output node; - } + let outputs = self.client.state.outputs.lock(); + if let Some(output) = outputs.values().next() { + break 'get_output output.node.clone(); } return Err(GetLayerSurfaceError::NoOutputs); } }; - log::info!("output = {:?}", output.global.pos.get()); if req.layer > OVERLAY { return Err(GetLayerSurfaceError::UnknownLayer(req.layer)); } diff --git a/src/ifs/zwp_linux_buffer_params_v1.rs b/src/ifs/zwp_linux_buffer_params_v1.rs index 789ce290..73da4b16 100644 --- a/src/ifs/zwp_linux_buffer_params_v1.rs +++ b/src/ifs/zwp_linux_buffer_params_v1.rs @@ -1,20 +1,27 @@ -use crate::client::ClientError; -use crate::drm::dma::{DmaBuf, DmaBufPlane}; -use crate::drm::INVALID_MODIFIER; -use crate::ifs::wl_buffer::WlBuffer; -use crate::ifs::zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::render::RenderError; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::utils::errorfmt::ErrorFmt; -use crate::wire::zwp_linux_buffer_params_v1::*; -use crate::wire::{WlBufferId, ZwpLinuxBufferParamsV1Id}; -use ahash::AHashMap; -use std::cell::{Cell, RefCell}; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::ClientError, + video::{ + dma::{DmaBuf, DmaBufPlane}, + INVALID_MODIFIER, + }, + ifs::{wl_buffer::WlBuffer, zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1}, + leaks::Tracker, + object::Object, + render::RenderError, + utils::{ + buffd::{MsgParser, MsgParserError}, + errorfmt::ErrorFmt, + }, + wire::{zwp_linux_buffer_params_v1::*, WlBufferId, ZwpLinuxBufferParamsV1Id}, + }, + ahash::AHashMap, + std::{ + cell::{Cell, RefCell}, + rc::Rc, + }, + thiserror::Error, +}; #[allow(dead_code)] const Y_INVERT: u32 = 1; diff --git a/src/ifs/zwp_linux_dmabuf_v1.rs b/src/ifs/zwp_linux_dmabuf_v1.rs index 5bcdcbd6..3019dc93 100644 --- a/src/ifs/zwp_linux_dmabuf_v1.rs +++ b/src/ifs/zwp_linux_dmabuf_v1.rs @@ -1,15 +1,17 @@ -use crate::client::{Client, ClientError}; -use crate::drm::INVALID_MODIFIER; -use crate::globals::{Global, GlobalName}; -use crate::ifs::zwp_linux_buffer_params_v1::ZwpLinuxBufferParamsV1; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::zwp_linux_dmabuf_v1::*; -use crate::wire::ZwpLinuxDmabufV1Id; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + video::INVALID_MODIFIER, + globals::{Global, GlobalName}, + ifs::zwp_linux_buffer_params_v1::ZwpLinuxBufferParamsV1, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{zwp_linux_dmabuf_v1::*, ZwpLinuxDmabufV1Id}, + }, + std::rc::Rc, + thiserror::Error, +}; pub struct ZwpLinuxDmabufV1Global { name: GlobalName, diff --git a/src/ifs/zxdg_decoration_manager_v1.rs b/src/ifs/zxdg_decoration_manager_v1.rs index dd0ec01a..6a716b02 100644 --- a/src/ifs/zxdg_decoration_manager_v1.rs +++ b/src/ifs/zxdg_decoration_manager_v1.rs @@ -1,13 +1,16 @@ -use crate::client::{Client, ClientError}; -use crate::globals::{Global, GlobalName}; -use crate::ifs::zxdg_toplevel_decoration_v1::ZxdgToplevelDecorationV1; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::{MsgParser, MsgParserError}; -use crate::wire::zxdg_decoration_manager_v1::*; -use crate::wire::ZxdgDecorationManagerV1Id; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + globals::{Global, GlobalName}, + ifs::zxdg_toplevel_decoration_v1::ZxdgToplevelDecorationV1, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{zxdg_decoration_manager_v1::*, ZxdgDecorationManagerV1Id}, + }, + std::rc::Rc, + thiserror::Error, +}; pub struct ZxdgDecorationManagerV1Global { name: GlobalName, diff --git a/src/ifs/zxdg_output_manager_v1.rs b/src/ifs/zxdg_output_manager_v1.rs index 9ea700ae..4f6425e5 100644 --- a/src/ifs/zxdg_output_manager_v1.rs +++ b/src/ifs/zxdg_output_manager_v1.rs @@ -1,14 +1,16 @@ -use crate::client::{Client, ClientError}; -use crate::globals::{Global, GlobalName}; -use crate::ifs::zxdg_output_v1::ZxdgOutputV1; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::MsgParser; -use crate::utils::buffd::MsgParserError; -use crate::wire::zxdg_output_manager_v1::*; -use crate::wire::ZxdgOutputManagerV1Id; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + globals::{Global, GlobalName}, + ifs::zxdg_output_v1::ZxdgOutputV1, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{zxdg_output_manager_v1::*, ZxdgOutputManagerV1Id}, + }, + std::rc::Rc, + thiserror::Error, +}; pub struct ZxdgOutputManagerV1Global { name: GlobalName, diff --git a/src/ifs/zxdg_output_v1.rs b/src/ifs/zxdg_output_v1.rs index 11f0b188..a629844d 100644 --- a/src/ifs/zxdg_output_v1.rs +++ b/src/ifs/zxdg_output_v1.rs @@ -1,12 +1,15 @@ -use crate::client::{Client, ClientError}; -use crate::ifs::wl_output::{WlOutput, SEND_DONE_SINCE}; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::{MsgParser, MsgParserError}; -use crate::wire::zxdg_output_v1::*; -use crate::wire::ZxdgOutputV1Id; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + ifs::wl_output::{WlOutput, SEND_DONE_SINCE}, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{zxdg_output_v1::*, ZxdgOutputV1Id}, + }, + std::rc::Rc, + thiserror::Error, +}; #[allow(dead_code)] pub const NAME_SINCE: u32 = 2; diff --git a/src/ifs/zxdg_toplevel_decoration_v1.rs b/src/ifs/zxdg_toplevel_decoration_v1.rs index 59f213c4..fe50f706 100644 --- a/src/ifs/zxdg_toplevel_decoration_v1.rs +++ b/src/ifs/zxdg_toplevel_decoration_v1.rs @@ -1,12 +1,15 @@ -use crate::client::{Client, ClientError}; -use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::{Decoration, XdgToplevel}; -use crate::leaks::Tracker; -use crate::object::Object; -use crate::utils::buffd::{MsgParser, MsgParserError}; -use crate::wire::zxdg_toplevel_decoration_v1::*; -use crate::wire::ZxdgToplevelDecorationV1Id; -use std::rc::Rc; -use thiserror::Error; +use { + crate::{ + client::{Client, ClientError}, + ifs::wl_surface::xdg_surface::xdg_toplevel::{Decoration, XdgToplevel}, + leaks::Tracker, + object::Object, + utils::buffd::{MsgParser, MsgParserError}, + wire::{zxdg_toplevel_decoration_v1::*, ZxdgToplevelDecorationV1Id}, + }, + std::rc::Rc, + thiserror::Error, +}; const CLIENT_SIDE: u32 = 1; const SERVER_SIDE: u32 = 2; diff --git a/src/leaks.rs b/src/leaks.rs index d0ae4006..07780e2e 100644 --- a/src/leaks.rs +++ b/src/leaks.rs @@ -8,8 +8,7 @@ macro_rules! track { #[cfg(not(feature = "rc_tracking"))] mod leaks { - use crate::client::ClientId; - use std::marker::PhantomData; + use {crate::client::ClientId, std::marker::PhantomData}; pub fn init() { // nothing @@ -40,14 +39,21 @@ mod leaks { #[cfg(feature = "rc_tracking")] mod leaks { - use crate::client::ClientId; - use crate::utils::ptr_ext::{MutPtrExt, PtrExt}; - use ahash::{AHashMap, AHashSet}; - use backtrace::Backtrace; - use std::alloc::{GlobalAlloc, Layout}; - use std::marker::PhantomData; - use std::{any, mem, ptr}; - use uapi::c; + use { + crate::{ + client::ClientId, + utils::ptr_ext::{MutPtrExt, PtrExt}, + }, + ahash::{AHashMap, AHashSet}, + backtrace::Backtrace, + std::{ + alloc::{GlobalAlloc, Layout}, + any, + marker::PhantomData, + mem, ptr, + }, + uapi::c, + }; #[thread_local] static mut MAP: *mut AHashMap = ptr::null_mut(); diff --git a/src/libinput.rs b/src/libinput.rs index cbe95536..fc637456 100644 --- a/src/libinput.rs +++ b/src/libinput.rs @@ -5,28 +5,36 @@ pub mod device; pub mod event; mod sys; -use crate::libinput::consts::{ - LogPriority, LIBINPUT_LOG_PRIORITY_DEBUG, LIBINPUT_LOG_PRIORITY_ERROR, - LIBINPUT_LOG_PRIORITY_INFO, +use { + crate::{ + libinput::{ + consts::{ + LogPriority, LIBINPUT_LOG_PRIORITY_DEBUG, LIBINPUT_LOG_PRIORITY_ERROR, + LIBINPUT_LOG_PRIORITY_INFO, + }, + device::RegisteredDevice, + event::LibInputEvent, + sys::{ + libinput, libinput_device_ref, libinput_dispatch, libinput_get_event, + libinput_get_fd, libinput_interface, libinput_log_priority, + libinput_log_set_handler, libinput_log_set_priority, libinput_path_add_device, + libinput_path_create_context, libinput_unref, + }, + }, + udev::UdevError, + utils::{ + errorfmt::ErrorFmt, oserror::OsError, ptr_ext::PtrExt, trim::AsciiTrim, + vasprintf::vasprintf_, + }, + }, + bstr::ByteSlice, + std::{ + ffi::{CStr, VaList}, + rc::Rc, + }, + thiserror::Error, + uapi::{c, Errno, IntoUstr, OwnedFd}, }; -use crate::libinput::device::RegisteredDevice; -use crate::libinput::event::LibInputEvent; -use crate::libinput::sys::{ - libinput, libinput_device_ref, libinput_dispatch, libinput_get_event, libinput_get_fd, - libinput_interface, libinput_log_priority, libinput_log_set_handler, libinput_log_set_priority, - libinput_path_add_device, libinput_path_create_context, libinput_unref, -}; -use crate::udev::UdevError; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::oserror::OsError; -use crate::utils::ptr_ext::PtrExt; -use crate::utils::trim::AsciiTrim; -use crate::utils::vasprintf::vasprintf_; -use bstr::ByteSlice; -use std::ffi::{CStr, VaList}; -use std::rc::Rc; -use thiserror::Error; -use uapi::{c, Errno, IntoUstr, OwnedFd}; static INTERFACE: libinput_interface = libinput_interface { open_restricted, diff --git a/src/libinput/device.rs b/src/libinput/device.rs index e8d69fb0..29e6b524 100644 --- a/src/libinput/device.rs +++ b/src/libinput/device.rs @@ -1,15 +1,18 @@ -use crate::libinput::consts::{AccelProfile, DeviceCapability}; -use crate::libinput::sys::{ - libinput_device, libinput_device_config_accel_set_profile, - libinput_device_config_accel_set_speed, libinput_device_config_left_handed_set, - libinput_device_get_name, libinput_device_get_user_data, libinput_device_has_capability, - libinput_device_set_user_data, libinput_device_unref, libinput_path_remove_device, +use { + crate::libinput::{ + consts::{AccelProfile, DeviceCapability}, + sys::{ + libinput_device, libinput_device_config_accel_set_profile, + libinput_device_config_accel_set_speed, libinput_device_config_left_handed_set, + libinput_device_get_name, libinput_device_get_user_data, + libinput_device_has_capability, libinput_device_set_user_data, libinput_device_unref, + libinput_path_remove_device, + }, + LibInput, + }, + bstr::ByteSlice, + std::{ffi::CStr, marker::PhantomData, rc::Rc}, }; -use crate::libinput::LibInput; -use bstr::ByteSlice; -use std::ffi::CStr; -use std::marker::PhantomData; -use std::rc::Rc; pub struct LibInputDevice<'a> { pub(super) dev: *mut libinput_device, diff --git a/src/libinput/event.rs b/src/libinput/event.rs index 79e01db8..d2a01ec2 100644 --- a/src/libinput/event.rs +++ b/src/libinput/event.rs @@ -1,16 +1,20 @@ -use crate::libinput::consts::{ButtonState, EventType, KeyState, PointerAxis}; -use crate::libinput::device::LibInputDevice; -use crate::libinput::sys::{ - libinput_event, libinput_event_destroy, libinput_event_get_device, - libinput_event_get_keyboard_event, libinput_event_get_pointer_event, libinput_event_get_type, - libinput_event_keyboard, libinput_event_keyboard_get_key, - libinput_event_keyboard_get_key_state, libinput_event_keyboard_get_time_usec, - libinput_event_pointer, libinput_event_pointer_get_button, - libinput_event_pointer_get_button_state, libinput_event_pointer_get_dx, - libinput_event_pointer_get_dy, libinput_event_pointer_get_scroll_value_v120, - libinput_event_pointer_get_time_usec, libinput_event_pointer_has_axis, +use { + crate::libinput::{ + consts::{ButtonState, EventType, KeyState, PointerAxis}, + device::LibInputDevice, + sys::{ + libinput_event, libinput_event_destroy, libinput_event_get_device, + libinput_event_get_keyboard_event, libinput_event_get_pointer_event, + libinput_event_get_type, libinput_event_keyboard, libinput_event_keyboard_get_key, + libinput_event_keyboard_get_key_state, libinput_event_keyboard_get_time_usec, + libinput_event_pointer, libinput_event_pointer_get_button, + libinput_event_pointer_get_button_state, libinput_event_pointer_get_dx, + libinput_event_pointer_get_dy, libinput_event_pointer_get_scroll_value_v120, + libinput_event_pointer_get_time_usec, libinput_event_pointer_has_axis, + }, + }, + std::marker::PhantomData, }; -use std::marker::PhantomData; pub struct LibInputEvent<'a> { pub(super) event: *mut libinput_event, diff --git a/src/libinput/sys.rs b/src/libinput/sys.rs index edb7a1e8..890b1220 100644 --- a/src/libinput/sys.rs +++ b/src/libinput/sys.rs @@ -1,5 +1,4 @@ -use std::ffi::VaList; -use uapi::c; +use {std::ffi::VaList, uapi::c}; include!(concat!(env!("OUT_DIR"), "/libinput_tys.rs")); diff --git a/src/logger.rs b/src/logger.rs index 4830e3a8..0f5d817f 100644 --- a/src/logger.rs +++ b/src/logger.rs @@ -1,19 +1,21 @@ -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::oserror::OsError; -use crate::utils::ptr_ext::MutPtrExt; -use backtrace::Backtrace; -use bstr::{BStr, BString, ByteSlice}; -use log::{Level, Log, Metadata, Record}; -use std::cell::UnsafeCell; -use std::fs::DirBuilder; -use std::io::Write; -use std::os::unix::ffi::OsStringExt; -use std::os::unix::fs::DirBuilderExt; -use std::sync::atomic::AtomicU32; -use std::sync::atomic::Ordering::Relaxed; -use std::sync::Arc; -use std::time::SystemTime; -use uapi::{c, format_ustr, Errno, Fd, OwnedFd}; +use { + crate::utils::{errorfmt::ErrorFmt, oserror::OsError, ptr_ext::MutPtrExt}, + backtrace::Backtrace, + bstr::{BStr, BString, ByteSlice}, + log::{Level, Log, Metadata, Record}, + std::{ + cell::UnsafeCell, + fs::DirBuilder, + io::Write, + os::unix::{ffi::OsStringExt, fs::DirBuilderExt}, + sync::{ + atomic::{AtomicU32, Ordering::Relaxed}, + Arc, + }, + time::SystemTime, + }, + uapi::{c, format_ustr, Errno, Fd, OwnedFd}, +}; #[thread_local] static BUFFER: UnsafeCell> = UnsafeCell::new(Vec::new()); diff --git a/src/logind.rs b/src/logind.rs index dbe9298b..31f96b66 100644 --- a/src/logind.rs +++ b/src/logind.rs @@ -1,12 +1,18 @@ -use crate::dbus::{DbusError, DbusSocket, SignalHandler, FALSE}; -use crate::wire_dbus::org; -use crate::wire_dbus::org::freedesktop::login1::seat::SwitchToReply; -use crate::wire_dbus::org::freedesktop::login1::session::{ - PauseDevice, ResumeDevice, TakeDeviceReply, +use { + crate::{ + dbus::{DbusError, DbusSocket, SignalHandler, FALSE}, + wire_dbus::{ + org, + org::freedesktop::login1::{ + seat::SwitchToReply, + session::{PauseDevice, ResumeDevice, TakeDeviceReply}, + }, + }, + }, + std::rc::Rc, + thiserror::Error, + uapi::c, }; -use std::rc::Rc; -use thiserror::Error; -use uapi::c; const LOGIND_NAME: &str = "org.freedesktop.login1"; const MANAGER_PATH: &str = "/org/freedesktop/login1"; diff --git a/src/main.rs b/src/main.rs index fbb87e08..73ce7e09 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,9 @@ #![feature( - c_variadic, - thread_local, - label_break_value, - generic_associated_types, - extern_types + c_variadic, // https://github.com/rust-lang/rust/issues/44930 + thread_local, // https://github.com/rust-lang/rust/issues/29594 + label_break_value, // https://github.com/rust-lang/rust/issues/48594 + generic_associated_types, // https://github.com/rust-lang/rust/issues/44265 + extern_types, // https://github.com/rust-lang/rust/issues/43467 )] #![allow( clippy::len_zero, @@ -45,7 +45,7 @@ mod compositor; mod config; mod cursor; mod dbus; -mod drm; +mod video; mod edid; mod event_loop; mod fixed; diff --git a/src/object.rs b/src/object.rs index b7a5da87..a8037303 100644 --- a/src/object.rs +++ b/src/object.rs @@ -1,8 +1,10 @@ -use crate::client::ClientError; -use crate::utils::buffd::MsgParser; -use crate::wire::WlDisplayId; -use std::fmt::{Display, Formatter}; -use std::rc::Rc; +use { + crate::{client::ClientError, utils::buffd::MsgParser, wire::WlDisplayId}, + std::{ + fmt::{Display, Formatter}, + rc::Rc, + }, +}; pub const WL_DISPLAY_ID: WlDisplayId = WlDisplayId::from_raw(1); diff --git a/src/pango.rs b/src/pango.rs index 5b80b0e0..b64e66fd 100644 --- a/src/pango.rs +++ b/src/pango.rs @@ -1,12 +1,14 @@ #![allow(non_camel_case_types)] -use crate::pango::consts::{CairoFormat, CairoOperator, PangoEllipsizeMode}; -use crate::rect::Rect; -use std::cell::Cell; -use std::ptr; -use std::rc::Rc; -use thiserror::Error; -use uapi::{c, IntoUstr}; +use { + crate::{ + pango::consts::{CairoFormat, CairoOperator, PangoEllipsizeMode}, + rect::Rect, + }, + std::{cell::Cell, ptr, rc::Rc}, + thiserror::Error, + uapi::{c, IntoUstr}, +}; pub mod consts; diff --git a/src/rect.rs b/src/rect.rs index 2e179c41..8ead6d98 100644 --- a/src/rect.rs +++ b/src/rect.rs @@ -4,8 +4,10 @@ mod region; mod tests; pub use region::RegionBuilder; -use smallvec::SmallVec; -use std::fmt::{Debug, Formatter}; +use { + smallvec::SmallVec, + std::fmt::{Debug, Formatter}, +}; #[derive(Copy, Clone, Eq, PartialEq, Default)] pub struct Rect { diff --git a/src/rect/region.rs b/src/rect/region.rs index 0c8837fd..21c3f8d1 100644 --- a/src/rect/region.rs +++ b/src/rect/region.rs @@ -1,12 +1,12 @@ -use crate::rect::{Container, Rect, Region}; -use crate::utils::windows::WindowsExt; -use once_cell::unsync::Lazy; -use smallvec::SmallVec; -use std::cmp::Ordering; -use std::collections::BinaryHeap; -use std::mem; -use std::ops::Deref; -use std::rc::Rc; +use { + crate::{ + rect::{Container, Rect, Region}, + utils::windows::WindowsExt, + }, + once_cell::unsync::Lazy, + smallvec::SmallVec, + std::{cmp::Ordering, collections::BinaryHeap, mem, ops::Deref, rc::Rc}, +}; #[thread_local] static EMPTY: Lazy> = Lazy::new(|| { diff --git a/src/render.rs b/src/render.rs index ecbd4a19..58df24e4 100644 --- a/src/render.rs +++ b/src/render.rs @@ -18,10 +18,11 @@ macro_rules! egl_transparent { }; } -use crate::drm::drm::DrmError; -use crate::drm::gbm::GbmError; pub use renderer::*; -use thiserror::Error; +use { + crate::video::{drm::DrmError, gbm::GbmError}, + thiserror::Error, +}; mod egl; mod ext; @@ -30,8 +31,7 @@ mod proc; mod renderer; pub mod sys { - pub use super::egl::sys::*; - pub use super::gl::sys::*; + pub use super::{egl::sys::*, gl::sys::*}; } pub fn init() -> Result<(), RenderError> { diff --git a/src/render/egl.rs b/src/render/egl.rs index 3414f6a6..2108e95b 100644 --- a/src/render/egl.rs +++ b/src/render/egl.rs @@ -1,22 +1,26 @@ -use crate::render::egl::sys::{ - eglBindAPI, EGLAttrib, EGLLabelKHR, EGLenum, EGLint, EGL_DEBUG_MSG_CRITICAL_KHR, - EGL_DEBUG_MSG_ERROR_KHR, EGL_DEBUG_MSG_INFO_KHR, EGL_DEBUG_MSG_WARN_KHR, EGL_NONE, - EGL_OPENGL_ES_API, EGL_TRUE, +use { + crate::render::{ + egl::sys::{ + eglBindAPI, EGLAttrib, EGLLabelKHR, EGLenum, EGLint, EGL_DEBUG_MSG_CRITICAL_KHR, + EGL_DEBUG_MSG_ERROR_KHR, EGL_DEBUG_MSG_INFO_KHR, EGL_DEBUG_MSG_WARN_KHR, EGL_NONE, + EGL_OPENGL_ES_API, EGL_TRUE, + }, + ext::{get_client_ext, ClientExt}, + proc::ExtProc, + RenderError, + }, + bstr::ByteSlice, + log::Level, + once_cell::sync::Lazy, + std::ffi::CStr, + sys::{ + EGL_BAD_ACCESS, EGL_BAD_ALLOC, EGL_BAD_ATTRIBUTE, EGL_BAD_CONFIG, EGL_BAD_CONTEXT, + EGL_BAD_CURRENT_SURFACE, EGL_BAD_DEVICE_EXT, EGL_BAD_DISPLAY, EGL_BAD_MATCH, + EGL_BAD_NATIVE_PIXMAP, EGL_BAD_NATIVE_WINDOW, EGL_BAD_PARAMETER, EGL_BAD_SURFACE, + EGL_CONTEXT_LOST, EGL_NOT_INITIALIZED, EGL_SUCCESS, + }, + uapi::c, }; -use crate::render::ext::{get_client_ext, ClientExt}; -use crate::render::proc::ExtProc; -use crate::render::RenderError; -use bstr::ByteSlice; -use log::Level; -use once_cell::sync::Lazy; -use std::ffi::CStr; -use sys::{ - EGL_BAD_ACCESS, EGL_BAD_ALLOC, EGL_BAD_ATTRIBUTE, EGL_BAD_CONFIG, EGL_BAD_CONTEXT, - EGL_BAD_CURRENT_SURFACE, EGL_BAD_DEVICE_EXT, EGL_BAD_DISPLAY, EGL_BAD_MATCH, - EGL_BAD_NATIVE_PIXMAP, EGL_BAD_NATIVE_WINDOW, EGL_BAD_PARAMETER, EGL_BAD_SURFACE, - EGL_CONTEXT_LOST, EGL_NOT_INITIALIZED, EGL_SUCCESS, -}; -use uapi::c; pub mod context; pub mod display; diff --git a/src/render/egl/context.rs b/src/render/egl/context.rs index 97980e67..9a6b6ef1 100644 --- a/src/render/egl/context.rs +++ b/src/render/egl/context.rs @@ -1,10 +1,14 @@ -use crate::render::egl::display::EglDisplay; -use crate::render::egl::sys::{ - eglDestroyContext, eglMakeCurrent, EGLContext, EGLSurface, EGL_FALSE, EGL_TRUE, +use { + crate::render::{ + egl::{ + display::EglDisplay, + sys::{eglDestroyContext, eglMakeCurrent, EGLContext, EGLSurface, EGL_FALSE, EGL_TRUE}, + }, + ext::GlExt, + RenderError, + }, + std::rc::Rc, }; -use crate::render::ext::GlExt; -use crate::render::RenderError; -use std::rc::Rc; #[derive(Debug, Clone)] pub struct EglContext { diff --git a/src/render/egl/display.rs b/src/render/egl/display.rs index 6fdeedc6..47e9e395 100644 --- a/src/render/egl/display.rs +++ b/src/render/egl/display.rs @@ -1,30 +1,36 @@ -use crate::drm::dma::DmaBuf; -use crate::drm::drm::Drm; -use crate::drm::gbm::GbmDevice; -use crate::drm::INVALID_MODIFIER; -use crate::format::{formats, Format}; -use crate::render::egl::context::EglContext; -use crate::render::egl::image::EglImage; -use crate::render::egl::sys::{ - eglCreateContext, eglTerminate, EGLClientBuffer, EGLConfig, EGLContext, EGLDisplay, EGLint, - EGL_CONTEXT_CLIENT_VERSION, EGL_DMA_BUF_PLANE0_FD_EXT, EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT, - EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT, EGL_DMA_BUF_PLANE0_OFFSET_EXT, - EGL_DMA_BUF_PLANE0_PITCH_EXT, EGL_DMA_BUF_PLANE1_FD_EXT, EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT, - EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT, EGL_DMA_BUF_PLANE1_OFFSET_EXT, - EGL_DMA_BUF_PLANE1_PITCH_EXT, EGL_DMA_BUF_PLANE2_FD_EXT, EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT, - EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT, EGL_DMA_BUF_PLANE2_OFFSET_EXT, - EGL_DMA_BUF_PLANE2_PITCH_EXT, EGL_DMA_BUF_PLANE3_FD_EXT, EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT, - EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT, EGL_DMA_BUF_PLANE3_OFFSET_EXT, - EGL_DMA_BUF_PLANE3_PITCH_EXT, EGL_HEIGHT, EGL_IMAGE_PRESERVED_KHR, EGL_LINUX_DMA_BUF_EXT, - EGL_LINUX_DRM_FOURCC_EXT, EGL_NONE, EGL_TRUE, EGL_WIDTH, +use { + crate::{ + video::{dma::DmaBuf, drm::Drm, gbm::GbmDevice, INVALID_MODIFIER}, + format::{formats, Format}, + render::{ + egl::{ + context::EglContext, + image::EglImage, + sys::{ + eglCreateContext, eglTerminate, EGLClientBuffer, EGLConfig, EGLContext, + EGLDisplay, EGLint, EGL_CONTEXT_CLIENT_VERSION, EGL_DMA_BUF_PLANE0_FD_EXT, + EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT, EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT, + EGL_DMA_BUF_PLANE0_OFFSET_EXT, EGL_DMA_BUF_PLANE0_PITCH_EXT, + EGL_DMA_BUF_PLANE1_FD_EXT, EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT, + EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT, EGL_DMA_BUF_PLANE1_OFFSET_EXT, + EGL_DMA_BUF_PLANE1_PITCH_EXT, EGL_DMA_BUF_PLANE2_FD_EXT, + EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT, EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT, + EGL_DMA_BUF_PLANE2_OFFSET_EXT, EGL_DMA_BUF_PLANE2_PITCH_EXT, + EGL_DMA_BUF_PLANE3_FD_EXT, EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT, + EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT, EGL_DMA_BUF_PLANE3_OFFSET_EXT, + EGL_DMA_BUF_PLANE3_PITCH_EXT, EGL_HEIGHT, EGL_IMAGE_PRESERVED_KHR, + EGL_LINUX_DMA_BUF_EXT, EGL_LINUX_DRM_FOURCC_EXT, EGL_NONE, EGL_TRUE, EGL_WIDTH, + }, + PROCS, + }, + ext::{get_display_ext, get_gl_ext, DisplayExt, GlExt}, + sys::{eglInitialize, EGL_PLATFORM_GBM_KHR}, + RenderError, + }, + }, + ahash::AHashMap, + std::{ptr, rc::Rc}, }; -use crate::render::egl::PROCS; -use crate::render::ext::{get_display_ext, get_gl_ext, DisplayExt, GlExt}; -use crate::render::sys::{eglInitialize, EGL_PLATFORM_GBM_KHR}; -use crate::render::RenderError; -use ahash::AHashMap; -use std::ptr; -use std::rc::Rc; #[derive(Debug)] pub struct EglDisplay { diff --git a/src/render/egl/image.rs b/src/render/egl/image.rs index 62324f02..0b8b8988 100644 --- a/src/render/egl/image.rs +++ b/src/render/egl/image.rs @@ -1,7 +1,11 @@ -use crate::render::egl::display::EglDisplay; -use crate::render::egl::sys::{EGLImageKHR, EGL_FALSE}; -use crate::render::egl::PROCS; -use std::rc::Rc; +use { + crate::render::egl::{ + display::EglDisplay, + sys::{EGLImageKHR, EGL_FALSE}, + PROCS, + }, + std::rc::Rc, +}; pub struct EglImage { pub dpy: Rc, diff --git a/src/render/ext.rs b/src/render/ext.rs index 04254a44..e88e462f 100644 --- a/src/render/ext.rs +++ b/src/render/ext.rs @@ -1,12 +1,16 @@ -use crate::render::egl::sys::{eglQueryString, EGLDisplay, EGL_EXTENSIONS}; -use crate::render::gl::sys::{glGetString, GL_EXTENSIONS}; -use crate::utils::trim::AsciiTrim; -use ahash::AHashSet; -use bstr::ByteSlice; -use std::ffi::CStr; -use std::ops::BitOrAssign; -use std::str; -use uapi::c; +use { + crate::{ + render::{ + egl::sys::{eglQueryString, EGLDisplay, EGL_EXTENSIONS}, + gl::sys::{glGetString, GL_EXTENSIONS}, + }, + utils::trim::AsciiTrim, + }, + ahash::AHashSet, + bstr::ByteSlice, + std::{ffi::CStr, ops::BitOrAssign, str}, + uapi::c, +}; unsafe fn get_extensions(ext: *const c::c_char) -> Option> { if ext.is_null() { diff --git a/src/render/gl/frame_buffer.rs b/src/render/gl/frame_buffer.rs index 6e62cadc..7c5cad83 100644 --- a/src/render/gl/frame_buffer.rs +++ b/src/render/gl/frame_buffer.rs @@ -1,12 +1,19 @@ -use crate::rect::Rect; -use crate::render::egl::context::EglContext; -use crate::render::gl::render_buffer::GlRenderBuffer; -use crate::render::gl::sys::{glDeleteFramebuffers, GLuint}; -use crate::render::gl::texture::GlTexture; -use crate::render::sys::{glDisable, glEnable, glScissor, GL_SCISSOR_TEST}; -use crate::utils::ptr_ext::PtrExt; -use std::ptr; -use std::rc::Rc; +use { + crate::{ + rect::Rect, + render::{ + egl::context::EglContext, + gl::{ + render_buffer::GlRenderBuffer, + sys::{glDeleteFramebuffers, GLuint}, + texture::GlTexture, + }, + sys::{glDisable, glEnable, glScissor, GL_SCISSOR_TEST}, + }, + utils::ptr_ext::PtrExt, + }, + std::{ptr, rc::Rc}, +}; pub struct GlFrameBuffer { pub _rb: Option>, diff --git a/src/render/gl/program.rs b/src/render/gl/program.rs index f49b0826..759d7a81 100644 --- a/src/render/gl/program.rs +++ b/src/render/gl/program.rs @@ -1,13 +1,19 @@ -use crate::render::egl::context::EglContext; -use crate::render::gl::shader::GlShader; -use crate::render::gl::sys::{ - glAttachShader, glCreateProgram, glDeleteProgram, glDetachShader, glGetAttribLocation, - glGetProgramiv, glGetUniformLocation, glLinkProgram, GLint, GLuint, GL_FALSE, GL_LINK_STATUS, +use { + crate::render::{ + egl::context::EglContext, + gl::{ + shader::GlShader, + sys::{ + glAttachShader, glCreateProgram, glDeleteProgram, glDetachShader, + glGetAttribLocation, glGetProgramiv, glGetUniformLocation, glLinkProgram, GLint, + GLuint, GL_FALSE, GL_FRAGMENT_SHADER, GL_LINK_STATUS, GL_VERTEX_SHADER, + }, + }, + RenderError, + }, + std::rc::Rc, + uapi::Ustr, }; -use crate::render::gl::sys::{GL_FRAGMENT_SHADER, GL_VERTEX_SHADER}; -use crate::render::RenderError; -use std::rc::Rc; -use uapi::Ustr; pub struct GlProgram { pub _ctx: Rc, diff --git a/src/render/gl/render_buffer.rs b/src/render/gl/render_buffer.rs index af799de9..c053086e 100644 --- a/src/render/gl/render_buffer.rs +++ b/src/render/gl/render_buffer.rs @@ -1,14 +1,19 @@ -use crate::render::egl::context::EglContext; -use crate::render::egl::image::EglImage; -use crate::render::egl::PROCS; -use crate::render::gl::frame_buffer::GlFrameBuffer; -use crate::render::gl::sys::{ - glBindFramebuffer, glBindRenderbuffer, glCheckFramebufferStatus, glDeleteRenderbuffers, - glFramebufferRenderbuffer, glGenFramebuffers, glGenRenderbuffers, GLeglImageOES, GLuint, - GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER, GL_FRAMEBUFFER_COMPLETE, GL_RENDERBUFFER, +use { + crate::render::{ + egl::{context::EglContext, image::EglImage, PROCS}, + gl::{ + frame_buffer::GlFrameBuffer, + sys::{ + glBindFramebuffer, glBindRenderbuffer, glCheckFramebufferStatus, + glDeleteRenderbuffers, glFramebufferRenderbuffer, glGenFramebuffers, + glGenRenderbuffers, GLeglImageOES, GLuint, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER, + GL_FRAMEBUFFER_COMPLETE, GL_RENDERBUFFER, + }, + }, + RenderError, + }, + std::rc::Rc, }; -use crate::render::RenderError; -use std::rc::Rc; pub struct GlRenderBuffer { pub img: Rc, diff --git a/src/render/gl/shader.rs b/src/render/gl/shader.rs index 4dc294b6..037ef79c 100644 --- a/src/render/gl/shader.rs +++ b/src/render/gl/shader.rs @@ -1,11 +1,15 @@ -use crate::render::egl::context::EglContext; -use crate::render::gl::sys::{ - glCompileShader, glCreateShader, glDeleteShader, glGetShaderiv, glShaderSource, GLenum, GLuint, - GL_COMPILE_STATUS, GL_FALSE, +use { + crate::render::{ + egl::context::EglContext, + gl::sys::{ + glCompileShader, glCreateShader, glDeleteShader, glGetShaderiv, glShaderSource, GLenum, + GLuint, GL_COMPILE_STATUS, GL_FALSE, + }, + sys::GLint, + RenderError, + }, + std::rc::Rc, }; -use crate::render::sys::GLint; -use crate::render::RenderError; -use std::rc::Rc; pub struct GlShader { pub ctx: Rc, diff --git a/src/render/gl/texture.rs b/src/render/gl/texture.rs index 03b68979..5d94bf9b 100644 --- a/src/render/gl/texture.rs +++ b/src/render/gl/texture.rs @@ -1,20 +1,25 @@ -use crate::format::Format; -use crate::render::egl::context::EglContext; -use crate::render::egl::image::EglImage; -use crate::render::egl::PROCS; -use crate::render::gl::frame_buffer::GlFrameBuffer; -use crate::render::gl::sys::{ - glBindFramebuffer, glBindTexture, glCheckFramebufferStatus, glDeleteTextures, - glFramebufferTexture2D, glGenFramebuffers, glGenTextures, glPixelStorei, glTexImage2D, - glTexParameteri, GLint, GLuint, GL_CLAMP_TO_EDGE, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER, - GL_FRAMEBUFFER_COMPLETE, GL_LINEAR, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, - GL_TEXTURE_MIN_FILTER, GL_TEXTURE_WRAP_S, GL_TEXTURE_WRAP_T, GL_UNPACK_ROW_LENGTH_EXT, +use { + crate::{ + format::Format, + render::{ + egl::{context::EglContext, image::EglImage, PROCS}, + gl::{ + frame_buffer::GlFrameBuffer, + sys::{ + glBindFramebuffer, glBindTexture, glCheckFramebufferStatus, glDeleteTextures, + glFramebufferTexture2D, glGenFramebuffers, glGenTextures, glPixelStorei, + glTexImage2D, glTexParameteri, GLint, GLuint, GL_CLAMP_TO_EDGE, + GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER, GL_FRAMEBUFFER_COMPLETE, GL_LINEAR, + GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_FILTER, GL_TEXTURE_WRAP_S, + GL_TEXTURE_WRAP_T, GL_UNPACK_ROW_LENGTH_EXT, + }, + }, + sys::GLeglImageOES, + RenderError, + }, + }, + std::{cell::Cell, ptr, rc::Rc}, }; -use crate::render::sys::GLeglImageOES; -use crate::render::RenderError; -use std::cell::Cell; -use std::ptr; -use std::rc::Rc; pub struct GlTexture { pub(super) ctx: Rc, diff --git a/src/render/renderer.rs b/src/render/renderer.rs index a3ca5e59..18f2ea99 100644 --- a/src/render/renderer.rs +++ b/src/render/renderer.rs @@ -1,8 +1,4 @@ -pub use context::*; -pub use framebuffer::*; -pub use image::*; -pub use renderer::*; -pub use texture::*; +pub use {context::*, framebuffer::*, image::*, renderer::*, texture::*}; mod context; mod framebuffer; diff --git a/src/render/renderer/context.rs b/src/render/renderer/context.rs index ff26ae54..d1a70076 100644 --- a/src/render/renderer/context.rs +++ b/src/render/renderer/context.rs @@ -1,21 +1,28 @@ -use crate::drm::dma::DmaBuf; -use crate::drm::drm::{Drm, NodeType}; -use crate::format::{Format, XRGB8888}; -use crate::render::egl::context::EglContext; -use crate::render::egl::display::EglDisplay; -use crate::render::gl::program::GlProgram; -use crate::render::gl::render_buffer::GlRenderBuffer; -use crate::render::gl::sys::GLint; -use crate::render::gl::texture::GlTexture; -use crate::render::renderer::framebuffer::Framebuffer; -use crate::render::renderer::image::Image; -use crate::render::{RenderError, Texture}; -use ahash::AHashMap; -use std::cell::Cell; -use std::ffi::CString; -use std::fmt::{Debug, Formatter}; -use std::rc::Rc; -use uapi::ustr; +use { + crate::{ + video::{ + dma::DmaBuf, + drm::{Drm, NodeType}, + }, + format::{Format, XRGB8888}, + render::{ + egl::{context::EglContext, display::EglDisplay}, + gl::{ + program::GlProgram, render_buffer::GlRenderBuffer, sys::GLint, texture::GlTexture, + }, + renderer::{framebuffer::Framebuffer, image::Image}, + RenderError, Texture, + }, + }, + ahash::AHashMap, + std::{ + cell::Cell, + ffi::CString, + fmt::{Debug, Formatter}, + rc::Rc, + }, + uapi::ustr, +}; pub(super) struct TexProg { pub(super) prog: GlProgram, diff --git a/src/render/renderer/framebuffer.rs b/src/render/renderer/framebuffer.rs index f7c09c24..d45d1c2a 100644 --- a/src/render/renderer/framebuffer.rs +++ b/src/render/renderer/framebuffer.rs @@ -1,15 +1,25 @@ -use crate::rect::Rect; -use crate::render::gl::frame_buffer::GlFrameBuffer; -use crate::render::gl::sys::{ - glBindFramebuffer, glClear, glClearColor, glViewport, GL_COLOR_BUFFER_BIT, GL_FRAMEBUFFER, +use { + crate::{ + rect::Rect, + render::{ + gl::{ + frame_buffer::GlFrameBuffer, + sys::{ + glBindFramebuffer, glClear, glClearColor, glViewport, GL_COLOR_BUFFER_BIT, + GL_FRAMEBUFFER, + }, + }, + renderer::{context::RenderContext, renderer::Renderer}, + sys::{glBlendFunc, glFlush, GL_ONE, GL_ONE_MINUS_SRC_ALPHA}, + }, + state::State, + tree::Node, + }, + std::{ + fmt::{Debug, Formatter}, + rc::Rc, + }, }; -use crate::render::renderer::context::RenderContext; -use crate::render::renderer::renderer::Renderer; -use crate::render::sys::{glBlendFunc, glFlush, GL_ONE, GL_ONE_MINUS_SRC_ALPHA}; -use crate::state::State; -use crate::tree::Node; -use std::fmt::{Debug, Formatter}; -use std::rc::Rc; pub struct Framebuffer { pub(super) ctx: Rc, diff --git a/src/render/renderer/image.rs b/src/render/renderer/image.rs index dcd305b4..a85fa903 100644 --- a/src/render/renderer/image.rs +++ b/src/render/renderer/image.rs @@ -1,7 +1,9 @@ -use crate::render::egl::image::EglImage; -use crate::render::gl::texture::GlTexture; -use crate::render::{RenderContext, RenderError, Texture}; -use std::rc::Rc; +use { + crate::render::{ + egl::image::EglImage, gl::texture::GlTexture, RenderContext, RenderError, Texture, + }, + std::rc::Rc, +}; pub struct Image { pub(super) ctx: Rc, diff --git a/src/render/renderer/renderer.rs b/src/render/renderer/renderer.rs index 1af3b8e8..d3c51a3f 100644 --- a/src/render/renderer/renderer.rs +++ b/src/render/renderer/renderer.rs @@ -1,25 +1,35 @@ -use crate::format::{Format, ARGB8888}; -use crate::ifs::wl_buffer::WlBuffer; -use crate::ifs::wl_surface::xdg_surface::XdgSurface; -use crate::ifs::wl_surface::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1; -use crate::ifs::wl_surface::WlSurface; -use crate::rect::Rect; -use crate::render::gl::frame_buffer::{with_scissor, GlFrameBuffer}; -use crate::render::gl::sys::{ - glActiveTexture, glBindTexture, glDisableVertexAttribArray, glDrawArrays, - glEnableVertexAttribArray, glTexParameteri, glUniform1i, glUniform4f, glUseProgram, - glVertexAttribPointer, GL_FALSE, GL_FLOAT, GL_LINEAR, GL_TEXTURE0, GL_TEXTURE_2D, - GL_TEXTURE_MIN_FILTER, GL_TRIANGLES, GL_TRIANGLE_STRIP, +use { + crate::{ + format::{Format, ARGB8888}, + ifs::{ + wl_buffer::WlBuffer, + wl_surface::{ + xdg_surface::XdgSurface, zwlr_layer_surface_v1::ZwlrLayerSurfaceV1, WlSurface, + }, + }, + rect::Rect, + render::{ + gl::{ + frame_buffer::{with_scissor, GlFrameBuffer}, + sys::{ + glActiveTexture, glBindTexture, glDisableVertexAttribArray, glDrawArrays, + glEnableVertexAttribArray, glTexParameteri, glUniform1i, glUniform4f, + glUseProgram, glVertexAttribPointer, GL_FALSE, GL_FLOAT, GL_LINEAR, + GL_TEXTURE0, GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_TRIANGLES, + GL_TRIANGLE_STRIP, + }, + }, + renderer::context::RenderContext, + sys::{glDisable, glEnable, GL_BLEND}, + Texture, + }, + state::State, + theme::Color, + tree::{ContainerNode, FloatNode, Node, OutputNode, WorkspaceNode}, + utils::rc_eq::rc_eq, + }, + std::{ops::Deref, rc::Rc}, }; -use crate::render::renderer::context::RenderContext; -use crate::render::sys::{glDisable, glEnable, GL_BLEND}; -use crate::render::Texture; -use crate::state::State; -use crate::theme::Color; -use crate::tree::{ContainerNode, FloatNode, Node, OutputNode, WorkspaceNode}; -use crate::utils::rc_eq::rc_eq; -use std::ops::Deref; -use std::rc::Rc; pub struct Renderer<'a> { pub(super) ctx: &'a Rc, diff --git a/src/render/renderer/texture.rs b/src/render/renderer/texture.rs index 1eca86e0..9bdae5ea 100644 --- a/src/render/renderer/texture.rs +++ b/src/render/renderer/texture.rs @@ -1,6 +1,7 @@ -use crate::render::gl::texture::GlTexture; -use crate::render::renderer::context::RenderContext; -use std::rc::Rc; +use { + crate::render::{gl::texture::GlTexture, renderer::context::RenderContext}, + std::rc::Rc, +}; pub struct Texture { pub(super) ctx: Rc, diff --git a/src/sighand.rs b/src/sighand.rs index be37e1a7..9173b015 100644 --- a/src/sighand.rs +++ b/src/sighand.rs @@ -1,8 +1,9 @@ -use crate::event_loop::{EventLoop, EventLoopDispatcher, EventLoopError, EventLoopId}; -use std::error::Error; -use std::rc::Rc; -use thiserror::Error; -use uapi::{c, Errno, OwnedFd}; +use { + crate::event_loop::{EventLoop, EventLoopDispatcher, EventLoopError, EventLoopId}, + std::{error::Error, rc::Rc}, + thiserror::Error, + uapi::{c, Errno, OwnedFd}, +}; #[derive(Debug, Error)] pub enum SighandError { diff --git a/src/state.rs b/src/state.rs index ab8adcc1..783dd18e 100644 --- a/src/state.rs +++ b/src/state.rs @@ -1,37 +1,43 @@ -use crate::async_engine::{AsyncEngine, SpawnedFuture}; -use crate::backend::{ - Backend, BackendEvent, Connector, ConnectorId, ConnectorIds, InputDevice, InputDeviceId, - InputDeviceIds, MonitorInfo, +use { + crate::{ + async_engine::{AsyncEngine, SpawnedFuture}, + backend::{ + Backend, BackendEvent, Connector, ConnectorId, ConnectorIds, InputDevice, + InputDeviceId, InputDeviceIds, MonitorInfo, + }, + client::{Client, Clients}, + config::ConfigProxy, + cursor::ServerCursors, + dbus::Dbus, + event_loop::EventLoop, + forker::ForkerProxy, + globals::{Globals, GlobalsError, WaylandGlobal}, + ifs::{ + wl_seat::{SeatIds, WlSeatGlobal}, + wl_surface::NoneSurfaceExt, + }, + logger::Logger, + rect::Rect, + render::RenderContext, + theme::Theme, + tree::{ + ContainerNode, ContainerSplit, DisplayNode, FloatNode, Node, NodeIds, NodeVisitorBase, + OutputNode, WorkspaceNode, + }, + utils::{ + clonecell::CloneCell, copyhashmap::CopyHashMap, errorfmt::ErrorFmt, fdcloser::FdCloser, + linkedlist::LinkedList, queue::AsyncQueue, + }, + wheel::Wheel, + xkbcommon::{XkbContext, XkbKeymap}, + }, + ahash::AHashMap, + std::{ + cell::{Cell, RefCell}, + rc::Rc, + sync::Arc, + }, }; -use crate::client::{Client, Clients}; -use crate::config::ConfigProxy; -use crate::cursor::ServerCursors; -use crate::dbus::Dbus; -use crate::event_loop::EventLoop; -use crate::forker::ForkerProxy; -use crate::globals::{Globals, GlobalsError, WaylandGlobal}; -use crate::ifs::wl_seat::{SeatIds, WlSeatGlobal}; -use crate::ifs::wl_surface::NoneSurfaceExt; -use crate::logger::Logger; -use crate::rect::Rect; -use crate::render::RenderContext; -use crate::theme::Theme; -use crate::tree::walker::NodeVisitorBase; -use crate::tree::{ - ContainerNode, ContainerSplit, DisplayNode, FloatNode, Node, NodeIds, OutputNode, WorkspaceNode, -}; -use crate::utils::clonecell::CloneCell; -use crate::utils::copyhashmap::CopyHashMap; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::fdcloser::FdCloser; -use crate::utils::linkedlist::LinkedList; -use crate::utils::queue::AsyncQueue; -use crate::wheel::Wheel; -use crate::xkbcommon::{XkbContext, XkbKeymap}; -use ahash::AHashMap; -use std::cell::{Cell, RefCell}; -use std::rc::Rc; -use std::sync::Arc; pub struct State { pub xkb_ctx: XkbContext, @@ -68,6 +74,7 @@ pub struct State { pub fdcloser: Arc, pub logger: Arc, pub connectors: CopyHashMap>, + pub outputs: CopyHashMap>, } pub struct InputDeviceData { @@ -83,12 +90,16 @@ pub struct DeviceHandlerData { pub struct ConnectorData { pub connector: Rc, - pub monitor_info: CloneCell>>, pub handler: Cell>>, - pub node: CloneCell>>, pub connected: Cell, } +pub struct OutputData { + pub connector: Rc, + pub monitor_info: MonitorInfo, + pub node: Rc, +} + impl State { pub fn set_render_ctx(&self, ctx: &Rc) { let cursors = match ServerCursors::load(ctx) { @@ -160,22 +171,19 @@ impl State { Some(output) => output, _ => self.dummy_output.get().unwrap(), }; - if let Some(workspace) = output.workspace.get() { - if let Some(container) = workspace.container.get() { - container.append_child(node); - } else { - let container = ContainerNode::new( - self, - &workspace, - workspace.clone(), - node, - ContainerSplit::Horizontal, - ); - workspace.set_container(&container); - }; - return; - } - log::warn!("Output has no workspace set"); + let workspace = output.ensure_workspace(); + if let Some(container) = workspace.container.get() { + container.append_child(node); + } else { + let container = ContainerNode::new( + self, + &workspace, + workspace.clone(), + node, + ContainerSplit::Horizontal, + ); + workspace.set_container(&container); + }; } pub fn map_floating( diff --git a/src/tasks.rs b/src/tasks.rs index 354f56e7..8a75926b 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -4,11 +4,14 @@ mod input_device; mod slow_clients; mod start_backend; -use crate::state::State; -use crate::tasks::backend::BackendEventHandler; -use crate::tasks::slow_clients::SlowClientHandler; pub use start_backend::start_backend; -use std::rc::Rc; +use { + crate::{ + state::State, + tasks::{backend::BackendEventHandler, slow_clients::SlowClientHandler}, + }, + std::rc::Rc, +}; pub async fn handle_backend_events(state: Rc) { let mut beh = BackendEventHandler { state }; diff --git a/src/tasks/backend.rs b/src/tasks/backend.rs index afbdd379..02dad2e9 100644 --- a/src/tasks/backend.rs +++ b/src/tasks/backend.rs @@ -1,7 +1,11 @@ -use crate::backend::BackendEvent; -use crate::state::State; -use crate::tasks::{connector, input_device}; -use std::rc::Rc; +use { + crate::{ + backend::BackendEvent, + state::State, + tasks::{connector, input_device}, + }, + std::rc::Rc, +}; pub struct BackendEventHandler { pub state: Rc, diff --git a/src/tasks/connector.rs b/src/tasks/connector.rs index 3a0b751e..c84b98e6 100644 --- a/src/tasks/connector.rs +++ b/src/tasks/connector.rs @@ -1,20 +1,23 @@ -use crate::backend::{Connector, ConnectorEvent, ConnectorId, MonitorInfo}; -use crate::ifs::wl_output::WlOutputGlobal; -use crate::rect::Rect; -use crate::state::{ConnectorData, State}; -use crate::tree::{OutputNode, OutputRenderData}; -use crate::utils::asyncevent::AsyncEvent; -use crate::utils::clonecell::CloneCell; -use std::cell::{Cell, RefCell}; -use std::rc::Rc; +use { + crate::{ + backend::{Connector, ConnectorEvent, ConnectorId, MonitorInfo}, + ifs::wl_output::WlOutputGlobal, + rect::Rect, + state::{ConnectorData, OutputData, State}, + tree::{OutputNode, OutputRenderData}, + utils::{asyncevent::AsyncEvent, clonecell::CloneCell}, + }, + std::{ + cell::{Cell, RefCell}, + rc::Rc, + }, +}; pub fn handle(state: &Rc, connector: &Rc) { let id = connector.id(); let data = Rc::new(ConnectorData { connector: connector.clone(), - monitor_info: Default::default(), handler: Default::default(), - node: Default::default(), connected: Cell::new(false), }); let oh = ConnectorHandler { @@ -61,13 +64,8 @@ impl ConnectorHandler { } async fn handle_connected(&self, ae: &Rc, info: MonitorInfo) { - log::info!( - "Connector {} connected: {:#?}", - self.data.connector.kernel_id(), - info - ); + log::info!("Connector {} connected", self.data.connector.kernel_id()); self.data.connected.set(true); - self.data.monitor_info.set(Some(Rc::new(info.clone()))); let name = self.state.globals.name(); let x1 = self .state @@ -103,12 +101,16 @@ impl ConnectorHandler { state: self.state.clone(), is_dummy: false, }); - self.data.node.set(Some(on.clone())); + let output_data = Rc::new(OutputData { + connector: self.data.clone(), + monitor_info: info, + node: on.clone(), + }); + self.state.outputs.set(self.id, output_data); global.node.set(Some(on.clone())); if let Some(config) = self.state.config.get() { config.connector_connected(self.id); } - on.ensure_workspace(); self.state.root.outputs.set(self.id, on.clone()); self.state.add_global(&global); 'outer: loop { @@ -123,13 +125,14 @@ impl ConnectorHandler { } ae.triggered().await; } + log::info!("Connector {} disconnected", self.data.connector.kernel_id()); if let Some(config) = self.state.config.get() { config.connector_disconnected(self.id); } - self.data.node.take(); global.node.set(None); let _ = self.state.remove_global(&*global); self.state.root.outputs.remove(&self.id); self.data.connected.set(false); + self.state.outputs.remove(&self.id); } } diff --git a/src/tasks/input_device.rs b/src/tasks/input_device.rs index 1bbf767c..1c066429 100644 --- a/src/tasks/input_device.rs +++ b/src/tasks/input_device.rs @@ -1,7 +1,11 @@ -use crate::backend::InputDevice; -use crate::state::{DeviceHandlerData, InputDeviceData, State}; -use crate::utils::asyncevent::AsyncEvent; -use std::rc::Rc; +use { + crate::{ + backend::InputDevice, + state::{DeviceHandlerData, InputDeviceData, State}, + utils::asyncevent::AsyncEvent, + }, + std::rc::Rc, +}; pub fn handle(state: &Rc, dev: Rc) { let data = Rc::new(DeviceHandlerData { diff --git a/src/tasks/slow_clients.rs b/src/tasks/slow_clients.rs index c7411646..84e75758 100644 --- a/src/tasks/slow_clients.rs +++ b/src/tasks/slow_clients.rs @@ -1,5 +1,4 @@ -use crate::state::State; -use std::rc::Rc; +use {crate::state::State, std::rc::Rc}; pub struct SlowClientHandler { pub state: Rc, diff --git a/src/tasks/start_backend.rs b/src/tasks/start_backend.rs index 146c8546..e819dd93 100644 --- a/src/tasks/start_backend.rs +++ b/src/tasks/start_backend.rs @@ -1,9 +1,11 @@ -use crate::backends::metal; -use crate::backends::x::XBackend; -use crate::state::State; -use crate::utils::errorfmt::ErrorFmt; -use std::future::pending; -use std::rc::Rc; +use { + crate::{ + backends::{metal, x::XBackend}, + state::State, + utils::errorfmt::ErrorFmt, + }, + std::{future::pending, rc::Rc}, +}; pub async fn start_backend(state: Rc) { log::info!("Trying to start X backend"); diff --git a/src/text.rs b/src/text.rs index cf50b138..9e29dd1d 100644 --- a/src/text.rs +++ b/src/text.rs @@ -1,17 +1,20 @@ -use crate::format::ARGB8888; -use crate::pango::consts::{ - CAIRO_FORMAT_ARGB32, CAIRO_OPERATOR_SOURCE, PANGO_ELLIPSIZE_END, PANGO_SCALE, +use { + crate::{ + format::ARGB8888, + pango::{ + consts::{ + CAIRO_FORMAT_ARGB32, CAIRO_OPERATOR_SOURCE, PANGO_ELLIPSIZE_END, PANGO_SCALE, + }, + CairoContext, CairoImageSurface, PangoCairoContext, PangoError, PangoFontDescription, + PangoLayout, + }, + rect::Rect, + render::{RenderContext, RenderError, Texture}, + theme::Color, + }, + std::{ops::Neg, rc::Rc}, + thiserror::Error, }; -use crate::pango::{ - CairoContext, CairoImageSurface, PangoCairoContext, PangoError, PangoFontDescription, - PangoLayout, -}; -use crate::rect::Rect; -use crate::render::{RenderContext, RenderError, Texture}; -use crate::theme::Color; -use std::ops::Neg; -use std::rc::Rc; -use thiserror::Error; #[derive(Debug, Error)] pub enum TextError { diff --git a/src/time.rs b/src/time.rs index ad95015a..56a89109 100644 --- a/src/time.rs +++ b/src/time.rs @@ -1,9 +1,13 @@ -use std::cmp::Ordering; -use std::fmt::{Debug, Formatter}; -use std::ops::{Add, Sub}; -use std::time::Duration; -use thiserror::Error; -use uapi::c; +use { + std::{ + cmp::Ordering, + fmt::{Debug, Formatter}, + ops::{Add, Sub}, + time::Duration, + }, + thiserror::Error, + uapi::c, +}; #[derive(Debug, Error)] pub enum TimeError { diff --git a/src/tools/tool_client.rs b/src/tools/tool_client.rs index 93c4cd73..553b5d22 100644 --- a/src/tools/tool_client.rs +++ b/src/tools/tool_client.rs @@ -1,35 +1,43 @@ -use crate::async_engine::{AsyncEngine, AsyncError, SpawnedFuture}; -use crate::client::{EventFormatter, RequestParser}; -use crate::event_loop::{EventLoop, EventLoopError}; -use crate::logger::Logger; -use crate::object::{ObjectId, WL_DISPLAY_ID}; -use crate::utils::asyncevent::AsyncEvent; -use crate::utils::bitfield::Bitfield; -use crate::utils::buffd::{ - BufFdError, BufFdIn, BufFdOut, MsgFormatter, MsgParser, MsgParserError, OutBuffer, - OutBufferSwapchain, +use { + crate::{ + async_engine::{AsyncEngine, AsyncError, SpawnedFuture}, + client::{EventFormatter, RequestParser}, + event_loop::{EventLoop, EventLoopError}, + logger::Logger, + object::{ObjectId, WL_DISPLAY_ID}, + utils::{ + asyncevent::AsyncEvent, + bitfield::Bitfield, + buffd::{ + BufFdError, BufFdIn, BufFdOut, MsgFormatter, MsgParser, MsgParserError, OutBuffer, + OutBufferSwapchain, + }, + clonecell::CloneCell, + errorfmt::ErrorFmt, + numcell::NumCell, + oserror::OsError, + stack::Stack, + vec_ext::VecExt, + }, + wheel::{Wheel, WheelError}, + wire::{ + wl_callback, wl_display, wl_registry, JayCompositor, JayCompositorId, WlCallbackId, + WlRegistryId, + }, + }, + ahash::AHashMap, + log::Level, + std::{ + cell::{Cell, RefCell}, + collections::VecDeque, + future::{Future, Pending}, + mem, + rc::Rc, + sync::Arc, + }, + thiserror::Error, + uapi::{c, format_ustr}, }; -use crate::utils::clonecell::CloneCell; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::numcell::NumCell; -use crate::utils::oserror::OsError; -use crate::utils::stack::Stack; -use crate::utils::vec_ext::VecExt; -use crate::wheel::{Wheel, WheelError}; -use crate::wire::{ - wl_callback, wl_display, wl_registry, JayCompositor, JayCompositorId, WlCallbackId, - WlRegistryId, -}; -use ahash::AHashMap; -use log::Level; -use std::cell::{Cell, RefCell}; -use std::collections::VecDeque; -use std::future::{Future, Pending}; -use std::mem; -use std::rc::Rc; -use std::sync::Arc; -use thiserror::Error; -use uapi::{c, format_ustr}; #[derive(Debug, Error)] pub enum ToolClientError { diff --git a/src/tree.rs b/src/tree.rs index 5e5fe776..51d63925 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -1,31 +1,31 @@ -use crate::backend::{ConnectorId, KeyState, ScrollAxis}; -use crate::client::{Client, ClientId}; -use crate::cursor::KnownCursor; -use crate::fixed::Fixed; -use crate::ifs::wl_seat::{Dnd, NodeSeatState, WlSeatGlobal}; -use crate::ifs::wl_surface::xwindow::Xwindow; -use crate::ifs::wl_surface::WlSurface; -use crate::rect::Rect; -use crate::render::Renderer; -use crate::tree::walker::NodeVisitor; -use crate::utils::copyhashmap::CopyHashMap; -use crate::utils::linkedlist::LinkedList; -use crate::utils::numcell::NumCell; -use crate::xkbcommon::ModifierState; -pub use container::*; -pub use float::*; -use jay_config::Direction; -pub use output::*; -use std::fmt::{Debug, Display}; -use std::ops::Deref; -use std::rc::Rc; -pub use workspace::*; +use { + crate::{ + backend::{KeyState, ScrollAxis}, + client::{Client, ClientId}, + fixed::Fixed, + ifs::{ + wl_seat::{Dnd, NodeSeatState, WlSeatGlobal}, + wl_surface::WlSurface, + }, + rect::Rect, + render::Renderer, + utils::numcell::NumCell, + xkbcommon::ModifierState, + }, + jay_config::Direction, + std::{ + fmt::{Debug, Display}, + rc::Rc, + }, +}; +pub use {container::*, display::*, float::*, output::*, toplevel::*, walker::*, workspace::*}; mod container; +mod display; mod float; mod output; -pub mod toplevel; -pub mod walker; +mod toplevel; +mod walker; mod workspace; pub struct NodeIds { @@ -62,6 +62,7 @@ impl Display for NodeId { } } +#[derive(Copy, Clone, Eq, PartialEq)] pub enum FindTreeResult { AcceptsInput, Other, @@ -351,105 +352,3 @@ pub struct FoundNode { pub x: i32, pub y: i32, } - -tree_id!(ToplevelNodeId); - -pub struct DisplayNode { - pub id: NodeId, - pub outputs: CopyHashMap>, - pub stacked: LinkedList>, - pub xstacked: LinkedList>, - pub seat_state: NodeSeatState, -} - -impl DisplayNode { - pub fn new(id: NodeId) -> Self { - Self { - id, - outputs: Default::default(), - stacked: Default::default(), - xstacked: Default::default(), - seat_state: Default::default(), - } - } -} - -impl Node for DisplayNode { - fn id(&self) -> NodeId { - self.id - } - - fn seat_state(&self) -> &NodeSeatState { - &self.seat_state - } - - fn destroy_node(&self, _detach: bool) { - let mut outputs = self.outputs.lock(); - for output in outputs.values() { - output.destroy_node(false); - } - outputs.clear(); - for stacked in self.stacked.iter() { - stacked.destroy_node(false); - } - self.seat_state.destroy_node(self); - } - - fn visit(self: Rc, visitor: &mut dyn NodeVisitor) { - visitor.visit_display(&self); - } - - fn visit_children(&self, visitor: &mut dyn NodeVisitor) { - let outputs = self.outputs.lock(); - for (_, output) in outputs.deref() { - visitor.visit_output(output); - } - for stacked in self.stacked.iter() { - stacked.deref().clone().visit(visitor); - } - } - - fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec) -> FindTreeResult { - for stacked in self.stacked.rev_iter() { - let ext = stacked.absolute_position(); - if stacked.absolute_position_constrains_input() && !ext.contains(x, y) { - // TODO: make constrain always true - continue; - } - let (x, y) = ext.translate(x, y); - let idx = tree.len(); - tree.push(FoundNode { - node: stacked.deref().clone(), - x, - y, - }); - match stacked.find_tree_at(x, y, tree) { - FindTreeResult::AcceptsInput => { - return FindTreeResult::AcceptsInput; - } - FindTreeResult::Other => { - tree.drain(idx..); - } - } - } - let outputs = self.outputs.lock(); - for output in outputs.values() { - let pos = output.global.pos.get(); - if pos.contains(x, y) { - let (x, y) = pos.translate(x, y); - tree.push(FoundNode { - node: output.clone(), - x, - y, - }); - output.find_tree_at(x, y, tree); - break; - } - } - FindTreeResult::AcceptsInput - } - - fn pointer_focus(&self, seat: &Rc) { - seat.set_known_cursor(KnownCursor::Default); - } -} diff --git a/src/tree/container.rs b/src/tree/container.rs index 408e06e3..a155e93a 100644 --- a/src/tree/container.rs +++ b/src/tree/container.rs @@ -1,27 +1,36 @@ -use crate::backend::KeyState; -use crate::cursor::KnownCursor; -use crate::fixed::Fixed; -use crate::ifs::wl_seat::{NodeSeatState, SeatId, WlSeatGlobal, BTN_LEFT}; -use crate::rect::Rect; -use crate::render::{Renderer, Texture}; -use crate::theme::Color; -use crate::tree::walker::NodeVisitor; -use crate::tree::{FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode}; -use crate::utils::clonecell::CloneCell; -use crate::utils::linkedlist::{LinkedList, LinkedNode, NodeRef}; -use ahash::AHashMap; -use jay_config::{Axis, Direction}; -use std::cell::{Cell, RefCell}; +use { + crate::{ + backend::KeyState, + cursor::KnownCursor, + fixed::Fixed, + ifs::wl_seat::{NodeSeatState, SeatId, WlSeatGlobal, BTN_LEFT}, + rect::Rect, + render::{Renderer, Texture}, + theme::Color, + tree::{walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode}, + utils::{ + clonecell::CloneCell, + linkedlist::{LinkedList, LinkedNode, NodeRef}, + }, + }, + ahash::AHashMap, + jay_config::{Axis, Direction}, + std::cell::{Cell, RefCell}, +}; -use crate::state::State; -use crate::text; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::numcell::NumCell; -use crate::utils::rc_eq::rc_eq; -use std::fmt::{Debug, Formatter}; -use std::mem; -use std::ops::{Deref, DerefMut, Sub}; -use std::rc::Rc; +use { + crate::{ + state::State, + text, + utils::{errorfmt::ErrorFmt, numcell::NumCell, rc_eq::rc_eq}, + }, + std::{ + fmt::{Debug, Formatter}, + mem, + ops::{Deref, DerefMut, Sub}, + rc::Rc, + }, +}; #[allow(dead_code)] #[derive(Copy, Clone, Debug, Eq, PartialEq)] diff --git a/src/tree/display.rs b/src/tree/display.rs new file mode 100644 index 00000000..9d73cdcf --- /dev/null +++ b/src/tree/display.rs @@ -0,0 +1,140 @@ +use { + crate::{ + backend::ConnectorId, + cursor::KnownCursor, + ifs::{ + wl_seat::{NodeSeatState, WlSeatGlobal}, + wl_surface::xwindow::Xwindow, + zwlr_layer_shell_v1::{OVERLAY, TOP}, + }, + tree::{walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId, OutputNode}, + utils::{copyhashmap::CopyHashMap, linkedlist::LinkedList}, + }, + std::{ops::Deref, rc::Rc}, +}; + +pub struct DisplayNode { + pub id: NodeId, + pub outputs: CopyHashMap>, + pub stacked: LinkedList>, + pub xstacked: LinkedList>, + pub seat_state: NodeSeatState, +} + +impl DisplayNode { + pub fn new(id: NodeId) -> Self { + Self { + id, + outputs: Default::default(), + stacked: Default::default(), + xstacked: Default::default(), + seat_state: Default::default(), + } + } +} + +impl Node for DisplayNode { + fn id(&self) -> NodeId { + self.id + } + + fn seat_state(&self) -> &NodeSeatState { + &self.seat_state + } + + fn destroy_node(&self, _detach: bool) { + let mut outputs = self.outputs.lock(); + for output in outputs.values() { + output.destroy_node(false); + } + outputs.clear(); + for stacked in self.stacked.iter() { + stacked.destroy_node(false); + } + self.seat_state.destroy_node(self); + } + + fn visit(self: Rc, visitor: &mut dyn NodeVisitor) { + visitor.visit_display(&self); + } + + fn visit_children(&self, visitor: &mut dyn NodeVisitor) { + let outputs = self.outputs.lock(); + for (_, output) in outputs.deref() { + visitor.visit_output(output); + } + for stacked in self.stacked.iter() { + stacked.deref().clone().visit(visitor); + } + } + + fn find_tree_at(&self, x: i32, y: i32, tree: &mut Vec) -> FindTreeResult { + let outputs = self.outputs.lock(); + for output in outputs.values() { + let pos = output.global.pos.get(); + if pos.contains(x, y) { + let (x, y) = pos.translate(x, y); + tree.push(FoundNode { + node: output.clone(), + x, + y, + }); + let len = tree.len(); + for layer in [OVERLAY, TOP] { + for surface in output.layers[layer as usize].rev_iter() { + let pos = surface.absolute_position(); + if pos.contains(x, y) { + let (x, y) = pos.translate(x, y); + if surface.find_tree_at(x, y, tree) == FindTreeResult::AcceptsInput { + return FindTreeResult::AcceptsInput; + } + tree.truncate(len); + } + } + } + tree.pop(); + break; + } + } + for stacked in self.stacked.rev_iter() { + let ext = stacked.absolute_position(); + if stacked.absolute_position_constrains_input() && !ext.contains(x, y) { + // TODO: make constrain always true + continue; + } + let (x, y) = ext.translate(x, y); + let idx = tree.len(); + tree.push(FoundNode { + node: stacked.deref().clone(), + x, + y, + }); + match stacked.find_tree_at(x, y, tree) { + FindTreeResult::AcceptsInput => { + return FindTreeResult::AcceptsInput; + } + FindTreeResult::Other => { + tree.drain(idx..); + } + } + } + for output in outputs.values() { + let pos = output.global.pos.get(); + if pos.contains(x, y) { + let (x, y) = pos.translate(x, y); + tree.push(FoundNode { + node: output.clone(), + x, + y, + }); + output.find_tree_at(x, y, tree); + break; + } + } + FindTreeResult::AcceptsInput + } + + fn pointer_focus(&self, seat: &Rc) { + seat.set_known_cursor(KnownCursor::Default); + } +} diff --git a/src/tree/float.rs b/src/tree/float.rs index 20296c86..5ba18f7b 100644 --- a/src/tree/float.rs +++ b/src/tree/float.rs @@ -1,23 +1,26 @@ -use crate::backend::KeyState; -use crate::cursor::KnownCursor; -use crate::fixed::Fixed; -use crate::ifs::wl_seat::{NodeSeatState, SeatId, WlSeatGlobal, BTN_LEFT}; -use crate::rect::Rect; -use crate::render::{Renderer, Texture}; -use crate::state::State; -use crate::text; -use crate::theme::Color; -use crate::tree::walker::NodeVisitor; -use crate::tree::{FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode}; -use crate::utils::clonecell::CloneCell; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::linkedlist::LinkedNode; -use ahash::AHashMap; -use std::cell::{Cell, RefCell}; -use std::fmt::{Debug, Formatter}; -use std::mem; -use std::ops::Deref; -use std::rc::Rc; +use { + crate::{ + backend::KeyState, + cursor::KnownCursor, + fixed::Fixed, + ifs::wl_seat::{NodeSeatState, SeatId, WlSeatGlobal, BTN_LEFT}, + rect::Rect, + render::{Renderer, Texture}, + state::State, + text, + theme::Color, + tree::{walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode}, + utils::{clonecell::CloneCell, errorfmt::ErrorFmt, linkedlist::LinkedNode}, + }, + ahash::AHashMap, + std::{ + cell::{Cell, RefCell}, + fmt::{Debug, Formatter}, + mem, + ops::Deref, + rc::Rc, + }, +}; tree_id!(FloatNodeId); pub struct FloatNode { diff --git a/src/tree/output.rs b/src/tree/output.rs index 8e7dc4d0..36ddd99a 100644 --- a/src/tree/output.rs +++ b/src/tree/output.rs @@ -1,23 +1,28 @@ -use crate::backend::Mode; -use crate::cursor::KnownCursor; -use crate::fixed::Fixed; -use crate::ifs::wl_output::WlOutputGlobal; -use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal}; -use crate::ifs::wl_surface::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1; -use crate::rect::Rect; -use crate::render::{Renderer, Texture}; -use crate::state::State; -use crate::text; -use crate::theme::Color; -use crate::tree::walker::NodeVisitor; -use crate::tree::{FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode}; -use crate::utils::clonecell::CloneCell; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::linkedlist::LinkedList; -use std::cell::RefCell; -use std::fmt::{Debug, Formatter}; -use std::ops::{Deref, Sub}; -use std::rc::Rc; +use { + crate::{ + backend::Mode, + cursor::KnownCursor, + fixed::Fixed, + ifs::{ + wl_output::WlOutputGlobal, + wl_seat::{NodeSeatState, WlSeatGlobal}, + wl_surface::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1, + }, + rect::Rect, + render::{Renderer, Texture}, + state::State, + text, + theme::Color, + tree::{walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode}, + utils::{clonecell::CloneCell, errorfmt::ErrorFmt, linkedlist::LinkedList}, + }, + std::{ + cell::RefCell, + fmt::{Debug, Formatter}, + ops::{Deref, Sub}, + rc::Rc, + }, +}; tree_id!(OutputNodeId); pub struct OutputNode { @@ -78,9 +83,9 @@ impl OutputNode { } } - pub fn ensure_workspace(self: &Rc) { - if !self.workspaces.is_empty() { - return; + pub fn ensure_workspace(self: &Rc) -> Rc { + if let Some(ws) = self.workspace.get() { + return ws; } let name = 'name: { for i in 1.. { @@ -107,6 +112,7 @@ impl OutputNode { .set(Some(self.workspaces.add_last(workspace.clone()))); self.show_workspace(&workspace); self.update_render_data(); + workspace } pub fn show_workspace(&self, ws: &Rc) { @@ -238,10 +244,6 @@ impl Node for OutputNode { unimplemented!(); } - fn leave(&self, seat: &WlSeatGlobal) { - seat.leave_output(); - } - fn pointer_enter(self: Rc, seat: &Rc, _x: Fixed, _y: Fixed) { seat.enter_output(&self) } diff --git a/src/tree/toplevel.rs b/src/tree/toplevel.rs index 0e7c7d63..a756826a 100644 --- a/src/tree/toplevel.rs +++ b/src/tree/toplevel.rs @@ -1,11 +1,13 @@ -use crate::ifs::wl_seat::SeatId; -use crate::ifs::wl_surface::WlSurface; -use crate::tree::Node; -use crate::utils::linkedlist::LinkedNode; -use crate::utils::numcell::NumCell; -use crate::utils::smallmap::SmallMap; -use std::rc::Rc; +use { + crate::{ + ifs::{wl_seat::SeatId, wl_surface::WlSurface}, + tree::Node, + utils::{linkedlist::LinkedNode, numcell::NumCell, smallmap::SmallMap}, + }, + std::rc::Rc, +}; +tree_id!(ToplevelNodeId); pub trait ToplevelNode { fn data(&self) -> &ToplevelData; fn parent(&self) -> Option>; diff --git a/src/tree/walker.rs b/src/tree/walker.rs index ae8d4079..f1a2f9a8 100644 --- a/src/tree/walker.rs +++ b/src/tree/walker.rs @@ -1,10 +1,15 @@ -use crate::ifs::wl_surface::xdg_surface::xdg_popup::XdgPopup; -use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel; -use crate::ifs::wl_surface::xwindow::Xwindow; -use crate::ifs::wl_surface::zwlr_layer_surface_v1::ZwlrLayerSurfaceV1; -use crate::ifs::wl_surface::WlSurface; -use crate::tree::{ContainerNode, DisplayNode, FloatNode, Node, OutputNode, WorkspaceNode}; -use std::rc::Rc; +use { + crate::{ + ifs::wl_surface::{ + xdg_surface::{xdg_popup::XdgPopup, xdg_toplevel::XdgToplevel}, + xwindow::Xwindow, + zwlr_layer_surface_v1::ZwlrLayerSurfaceV1, + WlSurface, + }, + tree::{ContainerNode, DisplayNode, FloatNode, Node, OutputNode, WorkspaceNode}, + }, + std::rc::Rc, +}; pub trait NodeVisitorBase: Sized { fn visit_surface(&mut self, node: &Rc) { diff --git a/src/tree/workspace.rs b/src/tree/workspace.rs index f58e6196..7b8f0983 100644 --- a/src/tree/workspace.rs +++ b/src/tree/workspace.rs @@ -1,15 +1,20 @@ -use crate::cursor::KnownCursor; -use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal}; -use crate::rect::Rect; -use crate::render::Renderer; -use crate::tree::container::ContainerNode; -use crate::tree::walker::NodeVisitor; -use crate::tree::{FindTreeResult, FoundNode, Node, NodeId, OutputNode}; -use crate::utils::clonecell::CloneCell; -use crate::utils::linkedlist::{LinkedList, LinkedNode}; -use std::cell::Cell; -use std::fmt::Debug; -use std::rc::Rc; +use { + crate::{ + cursor::KnownCursor, + ifs::wl_seat::{NodeSeatState, WlSeatGlobal}, + rect::Rect, + render::Renderer, + tree::{ + container::ContainerNode, walker::NodeVisitor, FindTreeResult, FoundNode, Node, NodeId, + OutputNode, + }, + utils::{ + clonecell::CloneCell, + linkedlist::{LinkedList, LinkedNode}, + }, + }, + std::{cell::Cell, fmt::Debug, rc::Rc}, +}; tree_id!(WorkspaceNodeId); diff --git a/src/udev.rs b/src/udev.rs index fbb75a8f..7eb699ad 100644 --- a/src/udev.rs +++ b/src/udev.rs @@ -1,9 +1,8 @@ -use std::ffi::CStr; -use std::marker::PhantomData; -use std::ptr; -use std::rc::Rc; -use thiserror::Error; -use uapi::{c, Errno, IntoUstr}; +use { + std::{ffi::CStr, marker::PhantomData, ptr, rc::Rc}, + thiserror::Error, + uapi::{c, Errno, IntoUstr}, +}; #[link(name = "udev")] extern "C" { diff --git a/src/utils/asyncevent.rs b/src/utils/asyncevent.rs index a062b275..38421c58 100644 --- a/src/utils/asyncevent.rs +++ b/src/utils/asyncevent.rs @@ -1,8 +1,12 @@ -use crate::utils::numcell::NumCell; -use std::cell::Cell; -use std::future::Future; -use std::pin::Pin; -use std::task::{Context, Poll, Waker}; +use { + crate::utils::numcell::NumCell, + std::{ + cell::Cell, + future::Future, + pin::Pin, + task::{Context, Poll, Waker}, + }, +}; #[derive(Default)] pub struct AsyncEvent { diff --git a/src/utils/buffd.rs b/src/utils/buffd.rs index 91f087fd..d5b9aa96 100644 --- a/src/utils/buffd.rs +++ b/src/utils/buffd.rs @@ -1,9 +1,10 @@ -use crate::async_engine::AsyncError; -pub use buf_in::BufFdIn; -pub use buf_out::{BufFdOut, OutBuffer, OutBufferSwapchain}; -pub use formatter::MsgFormatter; -pub use parser::{MsgParser, MsgParserError}; -use thiserror::Error; +use {crate::async_engine::AsyncError, thiserror::Error}; +pub use { + buf_in::BufFdIn, + buf_out::{BufFdOut, OutBuffer, OutBufferSwapchain}, + formatter::MsgFormatter, + parser::{MsgParser, MsgParserError}, +}; mod buf_in; mod buf_out; diff --git a/src/utils/buffd/buf_in.rs b/src/utils/buffd/buf_in.rs index e350ea96..726547e0 100644 --- a/src/utils/buffd/buf_in.rs +++ b/src/utils/buffd/buf_in.rs @@ -1,8 +1,11 @@ -use crate::async_engine::AsyncFd; -use crate::utils::buffd::{BufFdError, BUF_SIZE, CMSG_BUF_SIZE, MAX_IN_FD}; -use std::collections::VecDeque; -use std::mem::MaybeUninit; -use uapi::{c, Errno, OwnedFd, Pod}; +use { + crate::{ + async_engine::AsyncFd, + utils::buffd::{BufFdError, BUF_SIZE, CMSG_BUF_SIZE, MAX_IN_FD}, + }, + std::{collections::VecDeque, mem::MaybeUninit}, + uapi::{c, Errno, OwnedFd, Pod}, +}; pub struct BufFdIn { fd: AsyncFd, diff --git a/src/utils/buffd/buf_out.rs b/src/utils/buffd/buf_out.rs index ebda6ced..2acdf088 100644 --- a/src/utils/buffd/buf_out.rs +++ b/src/utils/buffd/buf_out.rs @@ -1,12 +1,17 @@ -use crate::async_engine::{AsyncFd, Timeout}; -use crate::utils::buffd::{BufFdError, BUF_SIZE, CMSG_BUF_SIZE}; -use futures_util::future::Fuse; -use futures_util::{select, FutureExt}; -use std::collections::VecDeque; -use std::mem::MaybeUninit; -use std::rc::Rc; -use std::{mem, slice}; -use uapi::{c, Errno, OwnedFd}; +use { + crate::{ + async_engine::{AsyncFd, Timeout}, + utils::buffd::{BufFdError, BUF_SIZE, CMSG_BUF_SIZE}, + }, + futures_util::{future::Fuse, select, FutureExt}, + std::{ + collections::VecDeque, + mem::{self, MaybeUninit}, + rc::Rc, + slice, + }, + uapi::{c, Errno, OwnedFd}, +}; pub(super) const OUT_BUF_SIZE: usize = 2 * BUF_SIZE; diff --git a/src/utils/buffd/formatter.rs b/src/utils/buffd/formatter.rs index d98f2003..c3abdf2d 100644 --- a/src/utils/buffd/formatter.rs +++ b/src/utils/buffd/formatter.rs @@ -1,10 +1,12 @@ -use crate::fixed::Fixed; -use crate::object::ObjectId; -use crate::utils::buffd::buf_out::{MsgFds, OutBuffer}; -use std::mem; -use std::mem::MaybeUninit; -use std::rc::Rc; -use uapi::OwnedFd; +use { + crate::{ + fixed::Fixed, + object::ObjectId, + utils::buffd::buf_out::{MsgFds, OutBuffer}, + }, + std::{mem, mem::MaybeUninit, rc::Rc}, + uapi::OwnedFd, +}; pub struct MsgFormatter<'a> { buf: &'a mut OutBuffer, diff --git a/src/utils/buffd/parser.rs b/src/utils/buffd/parser.rs index ed544567..ce64a8ae 100644 --- a/src/utils/buffd/parser.rs +++ b/src/utils/buffd/parser.rs @@ -1,12 +1,10 @@ -use crate::fixed::Fixed; -use crate::globals::GlobalName; -use crate::object::ObjectId; -use crate::utils::buffd::BufFdIn; -use bstr::{BStr, ByteSlice}; -use std::rc::Rc; -use std::{mem, ptr}; -use thiserror::Error; -use uapi::{OwnedFd, Pod}; +use { + crate::{fixed::Fixed, globals::GlobalName, object::ObjectId, utils::buffd::BufFdIn}, + bstr::{BStr, ByteSlice}, + std::{mem, ptr, rc::Rc}, + thiserror::Error, + uapi::{OwnedFd, Pod}, +}; #[derive(Debug, Error)] pub enum MsgParserError { diff --git a/src/utils/bufio.rs b/src/utils/bufio.rs index aa2ba363..f3793da8 100644 --- a/src/utils/bufio.rs +++ b/src/utils/bufio.rs @@ -1,16 +1,23 @@ -use crate::async_engine::{AsyncError, AsyncFd}; -use crate::utils::oserror::OsError; -use crate::utils::queue::AsyncQueue; -use crate::utils::stack::Stack; -use crate::utils::vec_ext::{UninitVecExt, VecExt}; -use crate::utils::vecstorage::VecStorage; -use std::collections::VecDeque; -use std::mem; -use std::mem::MaybeUninit; -use std::ptr::NonNull; -use std::rc::Rc; -use thiserror::Error; -use uapi::{c, Errno, MaybeUninitSliceExt, Msghdr, MsghdrMut, OwnedFd}; +use { + crate::{ + async_engine::{AsyncError, AsyncFd}, + utils::{ + oserror::OsError, + queue::AsyncQueue, + stack::Stack, + vec_ext::{UninitVecExt, VecExt}, + vecstorage::VecStorage, + }, + }, + std::{ + collections::VecDeque, + mem::{self, MaybeUninit}, + ptr::NonNull, + rc::Rc, + }, + thiserror::Error, + uapi::{c, Errno, MaybeUninitSliceExt, Msghdr, MsghdrMut, OwnedFd}, +}; #[derive(Debug, Error)] pub enum BufIoError { diff --git a/src/utils/clonecell.rs b/src/utils/clonecell.rs index 7d935136..03d12037 100644 --- a/src/utils/clonecell.rs +++ b/src/utils/clonecell.rs @@ -1,10 +1,16 @@ -use crate::utils::linkedlist::NodeRef; -use crate::utils::ptr_ext::{MutPtrExt, PtrExt}; -use jay_config::keyboard::mods::Modifiers; -use std::cell::UnsafeCell; -use std::fmt::{Debug, Formatter}; -use std::mem; -use std::rc::{Rc, Weak}; +use { + crate::utils::{ + linkedlist::NodeRef, + ptr_ext::{MutPtrExt, PtrExt}, + }, + jay_config::keyboard::mods::Modifiers, + std::{ + cell::UnsafeCell, + fmt::{Debug, Formatter}, + mem, + rc::{Rc, Weak}, + }, +}; pub struct CloneCell { data: UnsafeCell, diff --git a/src/utils/copyhashmap.rs b/src/utils/copyhashmap.rs index c32c281c..7e9319ba 100644 --- a/src/utils/copyhashmap.rs +++ b/src/utils/copyhashmap.rs @@ -1,12 +1,18 @@ -use crate::utils::clonecell::UnsafeCellCloneSafe; -use crate::utils::ptr_ext::{MutPtrExt, PtrExt}; -use ahash::AHashMap; -use std::borrow::Borrow; -use std::cell::UnsafeCell; -use std::fmt::{Debug, Formatter}; -use std::hash::Hash; -use std::mem; -use std::ops::{Deref, DerefMut}; +use { + crate::utils::{ + clonecell::UnsafeCellCloneSafe, + ptr_ext::{MutPtrExt, PtrExt}, + }, + ahash::AHashMap, + std::{ + borrow::Borrow, + cell::UnsafeCell, + fmt::{Debug, Formatter}, + hash::Hash, + mem, + ops::{Deref, DerefMut}, + }, +}; pub struct CopyHashMap { map: UnsafeCell>, diff --git a/src/utils/errorfmt.rs b/src/utils/errorfmt.rs index b03bd63d..186cfe0c 100644 --- a/src/utils/errorfmt.rs +++ b/src/utils/errorfmt.rs @@ -1,5 +1,7 @@ -use std::error::Error; -use std::fmt::{Display, Formatter}; +use std::{ + error::Error, + fmt::{Display, Formatter}, +}; pub struct ErrorFmt(pub E); diff --git a/src/utils/fdcloser.rs b/src/utils/fdcloser.rs index 922602d2..d862626c 100644 --- a/src/utils/fdcloser.rs +++ b/src/utils/fdcloser.rs @@ -1,7 +1,11 @@ -use std::mem; -use std::rc::Rc; -use std::sync::{Arc, Condvar, Mutex}; -use uapi::OwnedFd; +use { + std::{ + mem, + rc::Rc, + sync::{Arc, Condvar, Mutex}, + }, + uapi::OwnedFd, +}; pub struct FdCloser { fds: Mutex>, diff --git a/src/utils/linkedlist.rs b/src/utils/linkedlist.rs index e895fd02..0a95aa22 100644 --- a/src/utils/linkedlist.rs +++ b/src/utils/linkedlist.rs @@ -1,10 +1,13 @@ -use crate::utils::numcell::NumCell; -use crate::utils::ptr_ext::PtrExt; -use std::cell::Cell; -use std::fmt::{Debug, Formatter}; -use std::mem; -use std::ops::Deref; -use std::ptr::NonNull; +use { + crate::utils::{numcell::NumCell, ptr_ext::PtrExt}, + std::{ + cell::Cell, + fmt::{Debug, Formatter}, + mem, + ops::Deref, + ptr::NonNull, + }, +}; pub struct LinkedList { root: LinkedNode, @@ -52,6 +55,7 @@ impl LinkedList { } } + #[allow(dead_code)] pub fn is_empty(&self) -> bool { self.last().is_none() } diff --git a/src/utils/nonblock.rs b/src/utils/nonblock.rs index 26828bb4..d855399b 100644 --- a/src/utils/nonblock.rs +++ b/src/utils/nonblock.rs @@ -1,5 +1,4 @@ -use crate::utils::oserror::OsError; -use uapi::c; +use {crate::utils::oserror::OsError, uapi::c}; pub fn set_nonblock(fd: c::c_int) -> Result<(), OsError> { let fl = uapi::fcntl_getfl(fd)?; diff --git a/src/utils/numcell.rs b/src/utils/numcell.rs index 8be91b98..7ef51ebe 100644 --- a/src/utils/numcell.rs +++ b/src/utils/numcell.rs @@ -1,6 +1,8 @@ -use std::cell::Cell; -use std::fmt::{Debug, Formatter}; -use std::ops::{Add, BitAnd, BitOr, Sub}; +use std::{ + cell::Cell, + fmt::{Debug, Formatter}, + ops::{Add, BitAnd, BitOr, Sub}, +}; #[derive(Default)] pub struct NumCell { diff --git a/src/utils/oserror.rs b/src/utils/oserror.rs index 67781b17..aec5f32e 100644 --- a/src/utils/oserror.rs +++ b/src/utils/oserror.rs @@ -1,8 +1,11 @@ -use once_cell::sync::Lazy; -use std::error::Error; -use std::fmt::{Display, Formatter}; -use uapi::c::c_int; -use uapi::{c, Errno}; +use { + once_cell::sync::Lazy, + std::{ + error::Error, + fmt::{Display, Formatter}, + }, + uapi::{c, c::c_int, Errno}, +}; static ERRORS: Lazy<&'static [Option<&'static str>]> = Lazy::new(|| { static MSGS: &[(c::c_int, &str)] = &[ diff --git a/src/utils/queue.rs b/src/utils/queue.rs index d9ab7d92..bcf88d88 100644 --- a/src/utils/queue.rs +++ b/src/utils/queue.rs @@ -1,9 +1,11 @@ -use std::cell::{Cell, RefCell}; -use std::collections::VecDeque; -use std::future::Future; -use std::mem; -use std::pin::Pin; -use std::task::{Context, Poll, Waker}; +use std::{ + cell::{Cell, RefCell}, + collections::VecDeque, + future::Future, + mem, + pin::Pin, + task::{Context, Poll, Waker}, +}; pub struct AsyncQueue { data: RefCell>, diff --git a/src/utils/run_toplevel.rs b/src/utils/run_toplevel.rs index 7552c8f2..f956630d 100644 --- a/src/utils/run_toplevel.rs +++ b/src/utils/run_toplevel.rs @@ -1,6 +1,10 @@ -use crate::async_engine::{AsyncEngine, SpawnedFuture}; -use crate::utils::queue::AsyncQueue; -use std::rc::Rc; +use { + crate::{ + async_engine::{AsyncEngine, SpawnedFuture}, + utils::queue::AsyncQueue, + }, + std::rc::Rc, +}; pub struct RunToplevelFuture { _future: SpawnedFuture<()>, diff --git a/src/utils/smallmap.rs b/src/utils/smallmap.rs index d72ae33f..2fe67a90 100644 --- a/src/utils/smallmap.rs +++ b/src/utils/smallmap.rs @@ -1,9 +1,15 @@ -use crate::utils::clonecell::UnsafeCellCloneSafe; -use crate::utils::ptr_ext::{MutPtrExt, PtrExt}; -use smallvec::SmallVec; -use std::cell::UnsafeCell; -use std::fmt::{Debug, Formatter}; -use std::mem; +use { + crate::utils::{ + clonecell::UnsafeCellCloneSafe, + ptr_ext::{MutPtrExt, PtrExt}, + }, + smallvec::SmallVec, + std::{ + cell::UnsafeCell, + fmt::{Debug, Formatter}, + mem, + }, +}; pub struct SmallMap { m: UnsafeCell>, diff --git a/src/utils/stack.rs b/src/utils/stack.rs index 65b87597..af446435 100644 --- a/src/utils/stack.rs +++ b/src/utils/stack.rs @@ -1,5 +1,7 @@ -use crate::utils::ptr_ext::{MutPtrExt, PtrExt}; -use std::cell::UnsafeCell; +use { + crate::utils::ptr_ext::{MutPtrExt, PtrExt}, + std::cell::UnsafeCell, +}; pub struct Stack { vec: UnsafeCell>, diff --git a/src/utils/syncqueue.rs b/src/utils/syncqueue.rs index f580ae78..c292c9d7 100644 --- a/src/utils/syncqueue.rs +++ b/src/utils/syncqueue.rs @@ -1,7 +1,7 @@ -use crate::utils::ptr_ext::MutPtrExt; -use std::cell::UnsafeCell; -use std::collections::VecDeque; -use std::mem; +use { + crate::utils::ptr_ext::MutPtrExt, + std::{cell::UnsafeCell, collections::VecDeque, mem}, +}; #[derive(Debug)] pub struct SyncQueue { diff --git a/src/utils/tri.rs b/src/utils/tri.rs index 353a05cc..1384c0ad 100644 --- a/src/utils/tri.rs +++ b/src/utils/tri.rs @@ -1,7 +1,9 @@ -use std::future::Future; -use std::marker::PhantomData; -use std::pin::Pin; -use std::task::{Context, Poll}; +use std::{ + future::Future, + marker::PhantomData, + pin::Pin, + task::{Context, Poll}, +}; pub trait Try: Sized { fn tri(f: F) -> Result<(), Self> diff --git a/src/utils/vasprintf.rs b/src/utils/vasprintf.rs index f4411812..e7a0dac1 100644 --- a/src/utils/vasprintf.rs +++ b/src/utils/vasprintf.rs @@ -1,7 +1,11 @@ -use std::ffi::{CStr, VaList}; -use std::ops::Deref; -use std::ptr; -use uapi::c; +use { + std::{ + ffi::{CStr, VaList}, + ops::Deref, + ptr, + }, + uapi::c, +}; extern "C" { fn vasprintf(strp: *mut *mut c::c_char, fmt: *const c::c_char, ap: VaList) -> c::c_int; diff --git a/src/utils/vec_ext.rs b/src/utils/vec_ext.rs index 1291a8e9..2d55dd2b 100644 --- a/src/utils/vec_ext.rs +++ b/src/utils/vec_ext.rs @@ -1,6 +1,4 @@ -use std::mem::MaybeUninit; -use std::ops::Range; -use std::slice; +use std::{mem::MaybeUninit, ops::Range, slice}; pub trait VecExt { fn split_at_spare_mut_ext(&mut self) -> (&mut [T], &mut [MaybeUninit]); diff --git a/src/utils/vecstorage.rs b/src/utils/vecstorage.rs index 6e00b88d..2a3daa39 100644 --- a/src/utils/vecstorage.rs +++ b/src/utils/vecstorage.rs @@ -1,5 +1,7 @@ -use std::mem::ManuallyDrop; -use std::ops::{Deref, DerefMut}; +use std::{ + mem::ManuallyDrop, + ops::{Deref, DerefMut}, +}; pub struct VecStorage { ptr: *mut T, diff --git a/src/drm.rs b/src/video.rs similarity index 100% rename from src/drm.rs rename to src/video.rs diff --git a/src/drm/dma.rs b/src/video/dma.rs similarity index 79% rename from src/drm/dma.rs rename to src/video/dma.rs index c2679eab..795074c1 100644 --- a/src/drm/dma.rs +++ b/src/video/dma.rs @@ -1,6 +1,4 @@ -use crate::format::Format; -use std::rc::Rc; -use uapi::OwnedFd; +use {crate::format::Format, std::rc::Rc, uapi::OwnedFd}; pub struct DmaBufPlane { pub offset: u32, diff --git a/src/drm/drm.rs b/src/video/drm.rs similarity index 95% rename from src/drm/drm.rs rename to src/video/drm.rs index f30a8d5e..ff3f45ac 100644 --- a/src/drm/drm.rs +++ b/src/video/drm.rs @@ -1,35 +1,39 @@ mod sys; -use crate::drm::drm::sys::{ - create_lease, drm_event, drm_event_vblank, gem_close, get_cap, get_device_name_from_fd2, - get_minor_name_from_fd, get_node_type_from_fd, get_nodes, mode_addfb2, mode_atomic, - mode_create_blob, mode_destroy_blob, mode_get_resources, mode_getconnector, mode_getencoder, - mode_getplane, mode_getplaneresources, mode_getprobblob, mode_getproperty, - mode_obj_getproperties, mode_rmfb, prime_fd_to_handle, set_client_cap, DRM_DISPLAY_MODE_LEN, - DRM_MODE_ATOMIC_TEST_ONLY, DRM_MODE_FB_MODIFIERS, DRM_MODE_OBJECT_BLOB, - DRM_MODE_OBJECT_CONNECTOR, DRM_MODE_OBJECT_CRTC, DRM_MODE_OBJECT_ENCODER, DRM_MODE_OBJECT_FB, - DRM_MODE_OBJECT_MODE, DRM_MODE_OBJECT_PLANE, DRM_MODE_OBJECT_PROPERTY, +use { + crate::{ + video::drm::sys::{ + create_lease, drm_event, drm_event_vblank, gem_close, get_cap, + get_device_name_from_fd2, get_minor_name_from_fd, get_node_type_from_fd, get_nodes, + mode_addfb2, mode_atomic, mode_create_blob, mode_destroy_blob, mode_get_resources, + mode_getconnector, mode_getencoder, mode_getplane, mode_getplaneresources, + mode_getprobblob, mode_getproperty, mode_obj_getproperties, mode_rmfb, + prime_fd_to_handle, set_client_cap, DRM_DISPLAY_MODE_LEN, DRM_MODE_ATOMIC_TEST_ONLY, + DRM_MODE_FB_MODIFIERS, DRM_MODE_OBJECT_BLOB, DRM_MODE_OBJECT_CONNECTOR, + DRM_MODE_OBJECT_CRTC, DRM_MODE_OBJECT_ENCODER, DRM_MODE_OBJECT_FB, + DRM_MODE_OBJECT_MODE, DRM_MODE_OBJECT_PLANE, DRM_MODE_OBJECT_PROPERTY, + }, + utils::oserror::OsError, + }, + ahash::AHashMap, + bstr::{BString, ByteSlice}, + std::{ + cell::RefCell, + ffi::CString, + fmt::{Debug, Display, Formatter}, + mem::{self, MaybeUninit}, + ops::Deref, + rc::{Rc, Weak}, + }, + thiserror::Error, + uapi::{c, Errno, OwnedFd, Pod, Ustring}, }; -use crate::utils::oserror::OsError; -use ahash::AHashMap; -use bstr::{BString, ByteSlice}; -use std::cell::RefCell; -use std::ffi::CString; -use std::fmt::{Debug, Display, Formatter}; -use std::mem; -use std::mem::MaybeUninit; -use std::ops::Deref; -use std::rc::{Rc, Weak}; -use thiserror::Error; -use uapi::{c, Errno, OwnedFd, Pod, Ustring}; -use crate::backend; -use crate::drm::dma::DmaBuf; -use crate::drm::INVALID_MODIFIER; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::stack::Stack; -use crate::utils::syncqueue::SyncQueue; -use crate::utils::vec_ext::VecExt; +use crate::{ + backend, + video::{dma::DmaBuf, INVALID_MODIFIER}, + utils::{errorfmt::ErrorFmt, stack::Stack, syncqueue::SyncQueue, vec_ext::VecExt}, +}; pub use sys::{ drm_mode_modeinfo, DRM_CLIENT_CAP_ATOMIC, DRM_MODE_ATOMIC_ALLOW_MODESET, DRM_MODE_ATOMIC_NONBLOCK, DRM_MODE_PAGE_FLIP_EVENT, diff --git a/src/drm/drm/sys.rs b/src/video/drm/sys.rs similarity index 97% rename from src/drm/drm/sys.rs rename to src/video/drm/sys.rs index 89aa9057..b61e810d 100644 --- a/src/drm/drm/sys.rs +++ b/src/video/drm/sys.rs @@ -1,20 +1,25 @@ #![allow(non_camel_case_types)] #![allow(non_upper_case_globals)] -use crate::drm::drm::{ - DrmBlob, DrmCardResources, DrmConnector, DrmConnectorInfo, DrmCrtc, DrmEncoder, DrmEncoderInfo, - DrmError, DrmFb, DrmModeInfo, DrmPlane, DrmPlaneInfo, DrmProperty, DrmPropertyDefinition, - DrmPropertyEnumValue, DrmPropertyType, DrmPropertyValue, NodeType, +use { + crate::{ + video::drm::{ + DrmBlob, DrmCardResources, DrmConnector, DrmConnectorInfo, DrmCrtc, DrmEncoder, + DrmEncoderInfo, DrmError, DrmFb, DrmModeInfo, DrmPlane, DrmPlaneInfo, DrmProperty, + DrmPropertyDefinition, DrmPropertyEnumValue, DrmPropertyType, DrmPropertyValue, + NodeType, + }, + utils::{bitflags::BitflagsExt, oserror::OsError, trim::AsciiTrim}, + }, + ahash::AHashMap, + bstr::ByteSlice, + std::{ + ffi::CString, + io::{BufRead, BufReader}, + mem, + }, + uapi::{c, OwnedFd, Pod, Ustring}, }; -use crate::utils::bitflags::BitflagsExt; -use crate::utils::oserror::OsError; -use crate::utils::trim::AsciiTrim; -use ahash::AHashMap; -use bstr::ByteSlice; -use std::ffi::CString; -use std::io::{BufRead, BufReader}; -use std::mem; -use uapi::{c, OwnedFd, Pod, Ustring}; pub unsafe fn ioctl(fd: c::c_int, request: c::c_ulong, t: &mut T) -> Result { let mut ret; diff --git a/src/drm/gbm.rs b/src/video/gbm.rs similarity index 93% rename from src/drm/gbm.rs rename to src/video/gbm.rs index 83d8d31d..45fad1ec 100644 --- a/src/drm/gbm.rs +++ b/src/video/gbm.rs @@ -1,12 +1,20 @@ -use crate::drm::dma::{DmaBuf, DmaBufPlane}; -use crate::drm::drm::{Drm, DrmError}; -use crate::drm::{ModifiedFormat, INVALID_MODIFIER}; -use crate::format::formats; -use std::fmt::{Debug, Formatter}; -use std::ptr; -use std::rc::Rc; -use thiserror::Error; -use uapi::{c, OwnedFd}; +use { + crate::{ + video::{ + dma::{DmaBuf, DmaBufPlane}, + drm::{Drm, DrmError}, + ModifiedFormat, INVALID_MODIFIER, + }, + format::formats, + }, + std::{ + fmt::{Debug, Formatter}, + ptr, + rc::Rc, + }, + thiserror::Error, + uapi::{c, OwnedFd}, +}; #[derive(Debug, Error)] pub enum GbmError { diff --git a/src/wheel.rs b/src/wheel.rs index 9c9aed97..7b0ab103 100644 --- a/src/wheel.rs +++ b/src/wheel.rs @@ -1,15 +1,20 @@ -use crate::event_loop::{EventLoop, EventLoopDispatcher, EventLoopError, EventLoopId}; -use crate::time::{Time, TimeError}; -use crate::utils::copyhashmap::CopyHashMap; -use crate::utils::numcell::NumCell; -use std::cell::{Cell, RefCell}; -use std::cmp::Reverse; -use std::collections::BinaryHeap; -use std::error::Error; -use std::rc::Rc; -use std::time::Duration; -use thiserror::Error; -use uapi::{c, OwnedFd}; +use { + crate::{ + event_loop::{EventLoop, EventLoopDispatcher, EventLoopError, EventLoopId}, + time::{Time, TimeError}, + utils::{copyhashmap::CopyHashMap, numcell::NumCell}, + }, + std::{ + cell::{Cell, RefCell}, + cmp::Reverse, + collections::BinaryHeap, + error::Error, + rc::Rc, + time::Duration, + }, + thiserror::Error, + uapi::{c, OwnedFd}, +}; #[derive(Debug, Error)] pub enum WheelError { diff --git a/src/wire_xcon.rs b/src/wire_xcon.rs index bacc90ec..36e05117 100644 --- a/src/wire_xcon.rs +++ b/src/wire_xcon.rs @@ -8,10 +8,11 @@ clippy::unnecessary_cast )] -use crate::xcon::{Formatter, Message, Parser, Request, XEvent, XconError}; -use bstr::BStr; -use std::borrow::Cow; -use std::rc::Rc; -use uapi::OwnedFd; +use { + crate::xcon::{Formatter, Message, Parser, Request, XEvent, XconError}, + bstr::BStr, + std::{borrow::Cow, rc::Rc}, + uapi::OwnedFd, +}; include!(concat!(env!("OUT_DIR"), "/wire_xcon.rs")); diff --git a/src/xcon.rs b/src/xcon.rs index 29f0c210..d8f5e218 100644 --- a/src/xcon.rs +++ b/src/xcon.rs @@ -1,40 +1,52 @@ -use crate::async_engine::{AsyncEngine, AsyncError, Phase, SpawnedFuture}; -use crate::utils::bufio::{BufIo, BufIoError, BufIoMessage}; -use crate::utils::clonecell::CloneCell; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::numcell::NumCell; -use crate::utils::oserror::OsError; -use crate::utils::queue::AsyncQueue; -use crate::utils::vec_ext::VecExt; -use crate::wire_xcon::{ - CreateGC, CreatePixmap, Extension, FreeGC, FreePixmap, GetInputFocus, GetProperty, - ListExtensions, PutImage, QueryExtension, RenderCreateCursor, RenderCreatePicture, - RenderQueryPictFormats, Setup, EXTENSIONS, +pub use crate::xcon::{ + formatter::Formatter, + parser::Parser, + wire_type::{Message, Request, XEvent}, +}; +use { + crate::{ + async_engine::{AsyncEngine, AsyncError, Phase, SpawnedFuture}, + utils::{ + bufio::{BufIo, BufIoError, BufIoMessage}, + clonecell::CloneCell, + errorfmt::ErrorFmt, + numcell::NumCell, + oserror::OsError, + queue::AsyncQueue, + vec_ext::VecExt, + }, + wire_xcon::{ + CreateGC, CreatePixmap, Extension, FreeGC, FreePixmap, GetInputFocus, GetProperty, + ListExtensions, PutImage, QueryExtension, RenderCreateCursor, RenderCreatePicture, + RenderQueryPictFormats, Setup, EXTENSIONS, + }, + xcon::{ + consts::{IMAGE_FORMAT_Z_PIXMAP, RENDER_PICT_TYPE_DIRECT}, + incoming::handle_incoming, + outgoing::handle_outgoing, + wire_type::SendEvent, + xauthority::{XAuthority, LOCAL, MIT_MAGIC_COOKIE}, + }, + }, + ahash::AHashMap, + bstr::{BString, ByteSlice}, + std::{ + any::TypeId, + cell::{Cell, RefCell}, + collections::VecDeque, + fmt::Debug, + future::Future, + io::Write, + mem::{self, MaybeUninit}, + ops::{Deref, DerefMut}, + pin::Pin, + ptr, + rc::{Rc, Weak}, + task::{Context, Poll, Waker}, + }, + thiserror::Error, + uapi::{c, OwnedFd}, }; -use crate::xcon::consts::{IMAGE_FORMAT_Z_PIXMAP, RENDER_PICT_TYPE_DIRECT}; -pub use crate::xcon::formatter::Formatter; -use crate::xcon::incoming::handle_incoming; -use crate::xcon::outgoing::handle_outgoing; -pub use crate::xcon::parser::Parser; -use crate::xcon::wire_type::SendEvent; -pub use crate::xcon::wire_type::{Message, Request, XEvent}; -use crate::xcon::xauthority::{XAuthority, LOCAL, MIT_MAGIC_COOKIE}; -use ahash::AHashMap; -use bstr::{BString, ByteSlice}; -use std::any::TypeId; -use std::cell::{Cell, RefCell}; -use std::collections::VecDeque; -use std::fmt::Debug; -use std::future::Future; -use std::io::Write; -use std::mem::MaybeUninit; -use std::ops::{Deref, DerefMut}; -use std::pin::Pin; -use std::rc::{Rc, Weak}; -use std::task::{Context, Poll, Waker}; -use std::{mem, ptr}; -use thiserror::Error; -use uapi::{c, OwnedFd}; pub mod consts; mod formatter; diff --git a/src/xcon/formatter.rs b/src/xcon/formatter.rs index 32977173..27de2239 100644 --- a/src/xcon/formatter.rs +++ b/src/xcon/formatter.rs @@ -1,6 +1,8 @@ -use crate::xcon::Message; -use std::rc::Rc; -use uapi::{AssertPacked, OwnedFd, Packed}; +use { + crate::xcon::Message, + std::rc::Rc, + uapi::{AssertPacked, OwnedFd, Packed}, +}; pub struct Formatter<'a> { fds: &'a mut Vec>, diff --git a/src/xcon/incoming.rs b/src/xcon/incoming.rs index bb595ba7..f940e08b 100644 --- a/src/xcon/incoming.rs +++ b/src/xcon/incoming.rs @@ -1,9 +1,12 @@ -use crate::utils::bufio::BufIoIncoming; -use crate::utils::errorfmt::ErrorFmt; -use crate::xcon::consts::XGE_EVENT; -use crate::xcon::{Event, ExtensionData, ExtensionIdRange, Parser, XconData, XconError}; -use std::mem; -use std::rc::Rc; +use { + crate::{ + utils::{bufio::BufIoIncoming, errorfmt::ErrorFmt}, + xcon::{ + consts::XGE_EVENT, Event, ExtensionData, ExtensionIdRange, Parser, XconData, XconError, + }, + }, + std::{mem, rc::Rc}, +}; pub(super) async fn handle_incoming(xorg: Rc, incoming: BufIoIncoming) { let mut incoming = Incoming { diff --git a/src/xcon/outgoing.rs b/src/xcon/outgoing.rs index 1cbe1269..6ae783fc 100644 --- a/src/xcon/outgoing.rs +++ b/src/xcon/outgoing.rs @@ -1,6 +1,7 @@ -use crate::utils::errorfmt::ErrorFmt; -use crate::xcon::XconData; -use std::rc::Rc; +use { + crate::{utils::errorfmt::ErrorFmt, xcon::XconData}, + std::rc::Rc, +}; pub(super) async fn handle_outgoing(socket: Rc) { if let Err(e) = socket.bufio.clone().outgoing().await { diff --git a/src/xcon/parser.rs b/src/xcon/parser.rs index 5f03a98a..31556c0b 100644 --- a/src/xcon/parser.rs +++ b/src/xcon/parser.rs @@ -1,11 +1,12 @@ -use crate::utils::ptr_ext::PtrExt; -use crate::xcon::wire_type::Message; -use crate::xcon::XconError; -use bstr::{BStr, ByteSlice}; -use std::borrow::Cow; -use std::mem; -use std::rc::Rc; -use uapi::{OwnedFd, Pod}; +use { + crate::{ + utils::ptr_ext::PtrExt, + xcon::{wire_type::Message, XconError}, + }, + bstr::{BStr, ByteSlice}, + std::{borrow::Cow, mem, rc::Rc}, + uapi::{OwnedFd, Pod}, +}; pub struct Parser<'a> { pos: usize, diff --git a/src/xcon/wire_type.rs b/src/xcon/wire_type.rs index d5cd7a7f..8860a38d 100644 --- a/src/xcon/wire_type.rs +++ b/src/xcon/wire_type.rs @@ -1,11 +1,9 @@ -use crate::xcon::formatter::Formatter; -use crate::xcon::parser::Parser; -use crate::xcon::XconError; -use bstr::{BStr, ByteSlice}; -use std::borrow::Cow; -use std::fmt::Debug; -use std::rc::Rc; -use uapi::OwnedFd; +use { + crate::xcon::{formatter::Formatter, parser::Parser, XconError}, + bstr::{BStr, ByteSlice}, + std::{borrow::Cow, fmt::Debug, rc::Rc}, + uapi::OwnedFd, +}; #[cold] fn unimplemented() -> ! { diff --git a/src/xcon/xauthority.rs b/src/xcon/xauthority.rs index 3bf6116b..32acd840 100644 --- a/src/xcon/xauthority.rs +++ b/src/xcon/xauthority.rs @@ -1,7 +1,8 @@ -use crate::xcon::XconError; -use bstr::{BString, ByteSlice}; -use std::fs::File; -use std::io::Read; +use { + crate::xcon::XconError, + bstr::{BString, ByteSlice}, + std::{fs::File, io::Read}, +}; pub const LOCAL: u16 = 256; diff --git a/src/xkbcommon.rs b/src/xkbcommon.rs index f909fafd..9088ee5a 100644 --- a/src/xkbcommon.rs +++ b/src/xkbcommon.rs @@ -4,18 +4,23 @@ mod consts; include!(concat!(env!("OUT_DIR"), "/xkbcommon_tys.rs")); -use bstr::{BStr, ByteSlice}; pub use consts::*; -use std::ffi::{CStr, VaList}; -use std::io::Write; -use std::ops::Deref; -use std::ptr; -use std::rc::Rc; +use { + bstr::{BStr, ByteSlice}, + std::{ + ffi::{CStr, VaList}, + io::Write, + ops::Deref, + ptr, + rc::Rc, + }, +}; -use crate::utils::ptr_ext::PtrExt; -use crate::utils::trim::AsciiTrim; -use thiserror::Error; -use uapi::{c, OwnedFd}; +use { + crate::utils::{ptr_ext::PtrExt, trim::AsciiTrim}, + thiserror::Error, + uapi::{c, OwnedFd}, +}; #[derive(Debug, Error)] pub enum XkbCommonError { diff --git a/src/xwayland.rs b/src/xwayland.rs index a69616da..bfa7bac8 100644 --- a/src/xwayland.rs +++ b/src/xwayland.rs @@ -1,25 +1,26 @@ mod xsocket; mod xwm; -use crate::async_engine::AsyncError; -use crate::client::ClientError; -use crate::forker::{ForkerError, ForkerProxy}; -use crate::ifs::wl_surface::xwindow::{Xwindow, XwindowData}; -use crate::ifs::wl_surface::WlSurface; -use crate::state::State; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::oserror::OsError; -use crate::utils::queue::AsyncQueue; -use crate::utils::tri::Try; -use crate::wire::WlSurfaceId; -use crate::xcon::XconError; -use crate::xwayland::xsocket::allocate_socket; -use crate::xwayland::xwm::Wm; -use bstr::ByteSlice; -use std::num::ParseIntError; -use std::rc::Rc; -use thiserror::Error; -use uapi::{c, pipe2, Errno, OwnedFd}; +use { + crate::{ + async_engine::AsyncError, + client::ClientError, + forker::{ForkerError, ForkerProxy}, + ifs::wl_surface::{ + xwindow::{Xwindow, XwindowData}, + WlSurface, + }, + state::State, + utils::{errorfmt::ErrorFmt, oserror::OsError, queue::AsyncQueue, tri::Try}, + wire::WlSurfaceId, + xcon::XconError, + xwayland::{xsocket::allocate_socket, xwm::Wm}, + }, + bstr::ByteSlice, + std::{num::ParseIntError, rc::Rc}, + thiserror::Error, + uapi::{c, pipe2, Errno, OwnedFd}, +}; #[derive(Debug, Error)] enum XWaylandError { diff --git a/src/xwayland/xsocket.rs b/src/xwayland/xsocket.rs index 34eba3db..38d4b6e5 100644 --- a/src/xwayland/xsocket.rs +++ b/src/xwayland/xsocket.rs @@ -1,8 +1,11 @@ -use crate::utils::errorfmt::ErrorFmt; -use crate::xwayland::XWaylandError; -use std::io::{Read, Write}; -use std::rc::Rc; -use uapi::{c, format_ustr, Errno, OwnedFd, Ustring}; +use { + crate::{utils::errorfmt::ErrorFmt, xwayland::XWaylandError}, + std::{ + io::{Read, Write}, + rc::Rc, + }, + uapi::{c, format_ustr, Errno, OwnedFd, Ustring}, +}; const SOCK_DIR: &str = "/tmp/.X11-unix"; diff --git a/src/xwayland/xwm.rs b/src/xwayland/xwm.rs index bdc3793e..59e5732d 100644 --- a/src/xwayland/xwm.rs +++ b/src/xwayland/xwm.rs @@ -1,43 +1,54 @@ -use crate::client::Client; -use crate::ifs::wl_surface::xwindow::{XInputModel, Xwindow, XwindowData}; -use crate::ifs::wl_surface::WlSurface; -use crate::rect::Rect; -use crate::state::State; -use crate::tree::Node; -use crate::utils::bitflags::BitflagsExt; -use crate::utils::errorfmt::ErrorFmt; -use crate::utils::linkedlist::LinkedList; -use crate::utils::queue::AsyncQueue; -use crate::wire::WlSurfaceId; -use crate::wire_xcon::{ - ChangeProperty, ChangeWindowAttributes, ClientMessage, CompositeRedirectSubwindows, - ConfigureNotify, ConfigureRequest, ConfigureWindow, ConfigureWindowValues, CreateNotify, - CreateWindow, CreateWindowValues, DestroyNotify, FocusIn, GetAtomName, GetGeometry, InternAtom, - KillClient, MapNotify, MapRequest, MapWindow, PropertyNotify, ResClientIdSpec, - ResQueryClientIds, SetInputFocus, SetSelectionOwner, UnmapNotify, +use { + crate::{ + client::Client, + ifs::wl_surface::{ + xwindow::{XInputModel, Xwindow, XwindowData}, + WlSurface, + }, + rect::Rect, + state::State, + tree::Node, + utils::{ + bitflags::BitflagsExt, errorfmt::ErrorFmt, linkedlist::LinkedList, queue::AsyncQueue, + }, + wire::WlSurfaceId, + wire_xcon::{ + ChangeProperty, ChangeWindowAttributes, ClientMessage, CompositeRedirectSubwindows, + ConfigureNotify, ConfigureRequest, ConfigureWindow, ConfigureWindowValues, + CreateNotify, CreateWindow, CreateWindowValues, DestroyNotify, FocusIn, GetAtomName, + GetGeometry, InternAtom, KillClient, MapNotify, MapRequest, MapWindow, PropertyNotify, + ResClientIdSpec, ResQueryClientIds, SetInputFocus, SetSelectionOwner, UnmapNotify, + }, + xcon::{ + consts::{ + ATOM_ATOM, ATOM_STRING, ATOM_WINDOW, ATOM_WM_CLASS, ATOM_WM_NAME, + ATOM_WM_SIZE_HINTS, ATOM_WM_TRANSIENT_FOR, COMPOSITE_REDIRECT_MANUAL, + CONFIG_WINDOW_HEIGHT, CONFIG_WINDOW_WIDTH, CONFIG_WINDOW_X, CONFIG_WINDOW_Y, + EVENT_MASK_FOCUS_CHANGE, EVENT_MASK_PROPERTY_CHANGE, + EVENT_MASK_SUBSTRUCTURE_NOTIFY, EVENT_MASK_SUBSTRUCTURE_REDIRECT, + ICCCM_WM_HINT_INPUT, ICCCM_WM_STATE_ICONIC, ICCCM_WM_STATE_NORMAL, + ICCCM_WM_STATE_WITHDRAWN, INPUT_FOCUS_POINTER_ROOT, MWM_HINTS_DECORATIONS_FIELD, + MWM_HINTS_FLAGS_FIELD, NOTIFY_DETAIL_POINTER, NOTIFY_MODE_GRAB, NOTIFY_MODE_UNGRAB, + PROP_MODE_REPLACE, RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID, STACK_MODE_ABOVE, + STACK_MODE_BELOW, WINDOW_CLASS_INPUT_OUTPUT, _NET_WM_STATE_ADD, + _NET_WM_STATE_REMOVE, _NET_WM_STATE_TOGGLE, + }, + Event, XEvent, Xcon, XconError, + }, + xwayland::{XWaylandError, XWaylandEvent}, + }, + ahash::{AHashMap, AHashSet}, + bstr::ByteSlice, + futures_util::{select, FutureExt}, + smallvec::SmallVec, + std::{ + borrow::Cow, + mem, + ops::{Deref, DerefMut}, + rc::Rc, + }, + uapi::OwnedFd, }; -use crate::xcon::consts::{ - ATOM_ATOM, ATOM_STRING, ATOM_WINDOW, ATOM_WM_CLASS, ATOM_WM_NAME, ATOM_WM_SIZE_HINTS, - ATOM_WM_TRANSIENT_FOR, COMPOSITE_REDIRECT_MANUAL, CONFIG_WINDOW_HEIGHT, CONFIG_WINDOW_WIDTH, - CONFIG_WINDOW_X, CONFIG_WINDOW_Y, EVENT_MASK_FOCUS_CHANGE, EVENT_MASK_PROPERTY_CHANGE, - EVENT_MASK_SUBSTRUCTURE_NOTIFY, EVENT_MASK_SUBSTRUCTURE_REDIRECT, ICCCM_WM_HINT_INPUT, - ICCCM_WM_STATE_ICONIC, ICCCM_WM_STATE_NORMAL, ICCCM_WM_STATE_WITHDRAWN, - INPUT_FOCUS_POINTER_ROOT, MWM_HINTS_DECORATIONS_FIELD, MWM_HINTS_FLAGS_FIELD, - NOTIFY_DETAIL_POINTER, NOTIFY_MODE_GRAB, NOTIFY_MODE_UNGRAB, PROP_MODE_REPLACE, - RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID, STACK_MODE_ABOVE, STACK_MODE_BELOW, - WINDOW_CLASS_INPUT_OUTPUT, _NET_WM_STATE_ADD, _NET_WM_STATE_REMOVE, _NET_WM_STATE_TOGGLE, -}; -use crate::xcon::{Event, XEvent, Xcon, XconError}; -use crate::xwayland::{XWaylandError, XWaylandEvent}; -use ahash::{AHashMap, AHashSet}; -use bstr::ByteSlice; -use futures_util::{select, FutureExt}; -use smallvec::SmallVec; -use std::borrow::Cow; -use std::mem; -use std::ops::{Deref, DerefMut}; -use std::rc::Rc; -use uapi::OwnedFd; atoms! { Atoms; diff --git a/wire-dbus/org.freedesktop.DBus.txt b/wire-dbus/org.freedesktop.DBus.txt index 5fee421e..a48da315 100644 --- a/wire-dbus/org.freedesktop.DBus.txt +++ b/wire-dbus/org.freedesktop.DBus.txt @@ -5,3 +5,5 @@ fn Hello() { fn AddMatch(rule: string) { } fn RemoveMatch(rule: string) { } + +fn UpdateActivationEnvironment(environment: array(dict(string, string))) { }