Skip to content

Commit

Permalink
anvil: Use nested imports
Browse files Browse the repository at this point in the history
  • Loading branch information
jplatte authored and vberger committed Oct 7, 2018
1 parent 943f02b commit 850ff69
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 123 deletions.
42 changes: 25 additions & 17 deletions anvil/src/glium_drawer.rs
@@ -1,24 +1,32 @@
use glium;
use glium::index::PrimitiveType;
use glium::texture::{MipmapsOption, Texture2d, UncompressedFloatFormat};
use glium::{Frame, GlObject, Surface};
use smithay::backend::graphics::egl::error::Result as EGLResult;
use smithay::backend::graphics::egl::wayland::{
BufferAccessError, EGLDisplay, EGLImages, EGLWaylandExtensions, Format,
use std::{
cell::{Ref, RefCell},
rc::Rc,
};
use smithay::backend::graphics::egl::EGLGraphicsBackend;
use smithay::backend::graphics::glium::GliumGraphicsBackend;
use smithay::wayland::compositor::roles::Role;
use smithay::wayland::compositor::{SubsurfaceRole, TraversalAction};
use smithay::wayland::shm::with_buffer_contents as shm_buffer_contents;
use smithay::wayland_server::protocol::wl_buffer;
use smithay::wayland_server::{Display, Resource};

use std::cell::{Ref, RefCell};
use std::rc::Rc;

use glium::{
self,
index::PrimitiveType,
texture::{MipmapsOption, Texture2d, UncompressedFloatFormat},
Frame, GlObject, Surface,
};
use slog::Logger;

use smithay::{
backend::graphics::{
egl::{
error::Result as EGLResult,
wayland::{BufferAccessError, EGLDisplay, EGLImages, EGLWaylandExtensions, Format},
EGLGraphicsBackend,
},
glium::GliumGraphicsBackend,
},
wayland::{
compositor::{roles::Role, SubsurfaceRole, TraversalAction},
shm::with_buffer_contents as shm_buffer_contents,
},
wayland_server::{protocol::wl_buffer, Display, Resource},
};

use shaders;
use shell::{MyCompositorToken, MyWindowMap};

Expand Down
28 changes: 17 additions & 11 deletions anvil/src/input_handler.rs
@@ -1,19 +1,25 @@
use std::cell::RefCell;
use std::process::Command;
use std::rc::Rc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::{
cell::RefCell,
process::Command,
rc::Rc,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
};

use slog::Logger;

use smithay::backend::input::{
self, Event, InputBackend, InputHandler, KeyState, KeyboardKeyEvent, PointerAxisEvent,
PointerButtonEvent, PointerMotionAbsoluteEvent, PointerMotionEvent,
};
#[cfg(feature = "udev")]
use smithay::backend::session::auto::AutoSession;
use smithay::wayland::seat::{keysyms as xkb, KeyboardHandle, Keysym, ModifiersState, PointerHandle};
use smithay::wayland_server::protocol::wl_pointer;
use smithay::{
backend::input::{
self, Event, InputBackend, InputHandler, KeyState, KeyboardKeyEvent, PointerAxisEvent,
PointerButtonEvent, PointerMotionAbsoluteEvent, PointerMotionEvent,
},
wayland::seat::{keysyms as xkb, KeyboardHandle, Keysym, ModifiersState, PointerHandle},
wayland_server::protocol::wl_pointer,
};

use shell::MyWindowMap;

Expand Down
3 changes: 1 addition & 2 deletions anvil/src/main.rs
Expand Up @@ -10,8 +10,7 @@ extern crate smithay;
extern crate xkbcommon;

use slog::Drain;
use smithay::wayland_server::calloop::EventLoop;
use smithay::wayland_server::Display;
use smithay::wayland_server::{calloop::EventLoop, Display};

#[macro_use]
mod shaders;
Expand Down
60 changes: 35 additions & 25 deletions anvil/src/raw_drm.rs
@@ -1,22 +1,29 @@
use std::cell::RefCell;
use std::fs::{File, OpenOptions};
use std::os::unix::io::AsRawFd;
use std::os::unix::io::RawFd;
use std::rc::Rc;
use std::time::Duration;

use smithay::backend::drm::{drm_device_bind, DrmBackend, DrmDevice, DrmHandler};
use smithay::backend::graphics::egl::wayland::EGLWaylandExtensions;
use smithay::drm::control::connector::{Info as ConnectorInfo, State as ConnectorState};
use smithay::drm::control::crtc;
use smithay::drm::control::encoder::Info as EncoderInfo;
use smithay::drm::control::{Device as ControlDevice, ResourceInfo};
use smithay::drm::result::Error as DrmError;
use smithay::drm::Device as BasicDevice;
use smithay::wayland::compositor::CompositorToken;
use smithay::wayland::shm::init_shm_global;
use smithay::wayland_server::calloop::EventLoop;
use smithay::wayland_server::Display;
use std::{
cell::RefCell,
fs::{File, OpenOptions},
os::unix::io::{AsRawFd, RawFd},
rc::Rc,
time::Duration,
};

use smithay::{
backend::{
drm::{drm_device_bind, DrmBackend, DrmDevice, DrmHandler},
graphics::egl::wayland::EGLWaylandExtensions,
},
drm::{
control::{
connector::{Info as ConnectorInfo, State as ConnectorState},
crtc,
encoder::Info as EncoderInfo,
Device as ControlDevice, ResourceInfo,
},
result::Error as DrmError,
Device as BasicDevice,
},
wayland::{compositor::CompositorToken, shm::init_shm_global},
wayland_server::{calloop::EventLoop, Display},
};

use glium::Surface;
use slog::Logger;
Expand Down Expand Up @@ -62,13 +69,16 @@ pub fn run_raw_drm(mut display: Display, mut event_loop: EventLoop<()>, log: Log
let encoder_info = EncoderInfo::load_from_device(&device, connector_info.encoders()[0]).unwrap();

// use the connected crtc if any
let crtc = encoder_info.current_crtc()
let crtc = encoder_info
.current_crtc()
// or use the first one that is compatible with the encoder
.unwrap_or_else(||
*res_handles.filter_crtcs(encoder_info.possible_crtcs())
.iter()
.next()
.unwrap());
.unwrap_or_else(|| {
*res_handles
.filter_crtcs(encoder_info.possible_crtcs())
.iter()
.next()
.unwrap()
});

// Assuming we found a good connector and loaded the info into `connector_info`
let mode = connector_info.modes()[0]; // Use first mode (usually highest resoltion, but in reality you should filter and sort and check and match with other connectors, if you use more then one.)
Expand Down
34 changes: 22 additions & 12 deletions anvil/src/shell.rs
@@ -1,19 +1,29 @@
use std::cell::RefCell;
use std::rc::Rc;
use std::sync::{Arc, Mutex};
use std::{
cell::RefCell,
rc::Rc,
sync::{Arc, Mutex},
};

use rand;

use smithay::wayland::compositor::{compositor_init, CompositorToken, SurfaceAttributes, SurfaceEvent};
use smithay::wayland::shell::legacy::{
wl_shell_init, ShellRequest, ShellState as WlShellState, ShellSurfaceKind, ShellSurfaceRole,
};
use smithay::wayland::shell::xdg::{
xdg_shell_init, PopupConfigure, ShellState as XdgShellState, ToplevelConfigure, XdgRequest,
XdgSurfaceRole,
use smithay::{
wayland::{
compositor::{compositor_init, CompositorToken, SurfaceAttributes, SurfaceEvent},
shell::{
legacy::{
wl_shell_init, ShellRequest, ShellState as WlShellState, ShellSurfaceKind, ShellSurfaceRole,
},
xdg::{
xdg_shell_init, PopupConfigure, ShellState as XdgShellState, ToplevelConfigure, XdgRequest,
XdgSurfaceRole,
},
},
},
wayland_server::{
protocol::{wl_buffer, wl_callback, wl_shell_surface, wl_surface},
Display, Resource,
},
};
use smithay::wayland_server::protocol::{wl_buffer, wl_callback, wl_shell_surface, wl_surface};
use smithay::wayland_server::{Display, Resource};

use window_map::{Kind as SurfaceKind, WindowMap};

Expand Down
3 changes: 1 addition & 2 deletions anvil/src/shm_load.rs
@@ -1,7 +1,6 @@
use std::borrow::Cow;

use smithay::wayland::shm::BufferData;
use smithay::wayland_server::protocol::wl_shm::Format;
use smithay::{wayland::shm::BufferData, wayland_server::protocol::wl_shm::Format};

use glium::texture::{ClientFormat, RawImage2d};

Expand Down
78 changes: 46 additions & 32 deletions anvil/src/udev.rs
@@ -1,39 +1,53 @@
use std::cell::RefCell;
use std::collections::HashMap;
use std::io::Error as IoError;
use std::path::PathBuf;
use std::rc::Rc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::time::Duration;
use std::{
cell::RefCell,
collections::HashMap,
io::Error as IoError,
path::PathBuf,
rc::Rc,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
time::Duration,
};

use glium::Surface;

use smithay::image::{ImageBuffer, Rgba};

use slog::Logger;

use smithay::backend::drm::{DevPath, DrmBackend, DrmDevice, DrmHandler};
use smithay::backend::graphics::egl::wayland::{EGLDisplay, EGLWaylandExtensions};
use smithay::backend::graphics::GraphicsBackend;
use smithay::backend::input::InputBackend;
use smithay::backend::libinput::{libinput_bind, LibinputInputBackend, LibinputSessionInterface};
use smithay::backend::session::auto::{auto_session_bind, AutoSession};
use smithay::backend::session::{Session, SessionNotifier};
use smithay::backend::udev::{primary_gpu, udev_backend_bind, SessionFdDrmDevice, UdevBackend, UdevHandler};
use smithay::drm::control::connector::{Info as ConnectorInfo, State as ConnectorState};
use smithay::drm::control::crtc;
use smithay::drm::control::encoder::Info as EncoderInfo;
use smithay::drm::control::{Device as ControlDevice, ResourceInfo};
use smithay::drm::result::Error as DrmError;
use smithay::input::Libinput;
use smithay::wayland::compositor::CompositorToken;
use smithay::wayland::output::{Mode, Output, PhysicalProperties};
use smithay::wayland::seat::{Seat, XkbConfig};
use smithay::wayland::shm::init_shm_global;
use smithay::wayland_server::calloop::EventLoop;
use smithay::wayland_server::protocol::wl_output;
use smithay::wayland_server::Display;
use smithay::{
backend::{
drm::{DevPath, DrmBackend, DrmDevice, DrmHandler},
graphics::{
egl::wayland::{EGLDisplay, EGLWaylandExtensions},
GraphicsBackend,
},
input::InputBackend,
libinput::{libinput_bind, LibinputInputBackend, LibinputSessionInterface},
session::{
auto::{auto_session_bind, AutoSession},
Session, SessionNotifier,
},
udev::{primary_gpu, udev_backend_bind, SessionFdDrmDevice, UdevBackend, UdevHandler},
},
drm::{
control::{
connector::{Info as ConnectorInfo, State as ConnectorState},
crtc,
encoder::Info as EncoderInfo,
Device as ControlDevice, ResourceInfo,
},
result::Error as DrmError,
},
image::{ImageBuffer, Rgba},
input::Libinput,
wayland::{
compositor::CompositorToken,
output::{Mode, Output, PhysicalProperties},
seat::{Seat, XkbConfig},
shm::init_shm_global,
},
wayland_server::{calloop::EventLoop, protocol::wl_output, Display},
};

use glium_drawer::GliumDrawer;
use input_handler::AnvilInputHandler;
Expand Down
18 changes: 11 additions & 7 deletions anvil/src/window_map.rs
@@ -1,10 +1,14 @@
use smithay::utils::Rectangle;
use smithay::wayland::compositor::roles::Role;
use smithay::wayland::compositor::{CompositorToken, SubsurfaceRole, SurfaceAttributes, TraversalAction};
use smithay::wayland::shell::legacy::{ShellSurface, ShellSurfaceRole};
use smithay::wayland::shell::xdg::{ToplevelSurface, XdgSurfaceRole};
use smithay::wayland_server::protocol::wl_surface;
use smithay::wayland_server::Resource;
use smithay::{
utils::Rectangle,
wayland::{
compositor::{roles::Role, CompositorToken, SubsurfaceRole, SurfaceAttributes, TraversalAction},
shell::{
legacy::{ShellSurface, ShellSurfaceRole},
xdg::{ToplevelSurface, XdgSurfaceRole},
},
},
wayland_server::{protocol::wl_surface, Resource},
};

pub enum Kind<U, R, SD, D> {
Xdg(ToplevelSurface<U, R, SD>),
Expand Down
34 changes: 19 additions & 15 deletions anvil/src/winit.rs
@@ -1,18 +1,22 @@
use std::cell::RefCell;
use std::rc::Rc;
use std::sync::atomic::AtomicBool;
use std::sync::Arc;

use smithay::backend::graphics::egl::wayland::EGLWaylandExtensions;
use smithay::backend::graphics::egl::EGLGraphicsBackend;
use smithay::backend::input::InputBackend;
use smithay::backend::winit;
use smithay::wayland::output::{Mode, Output, PhysicalProperties};
use smithay::wayland::seat::{Seat, XkbConfig};
use smithay::wayland::shm::init_shm_global;
use smithay::wayland_server::calloop::EventLoop;
use smithay::wayland_server::protocol::wl_output;
use smithay::wayland_server::Display;
use std::{
cell::RefCell,
rc::Rc,
sync::{atomic::AtomicBool, Arc},
};

use smithay::{
backend::{
graphics::egl::{wayland::EGLWaylandExtensions, EGLGraphicsBackend},
input::InputBackend,
winit,
},
wayland::{
output::{Mode, Output, PhysicalProperties},
seat::{Seat, XkbConfig},
shm::init_shm_global,
},
wayland_server::{calloop::EventLoop, protocol::wl_output, Display},
};

use slog::Logger;

Expand Down

0 comments on commit 850ff69

Please sign in to comment.