Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace #[macro_use] with normal use #808

Merged
merged 4 commits into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion druid-shell/src/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@

//! Keyboard event types and helpers

use super::keycodes::KeyCode;
use std::fmt;

use super::keycodes::KeyCode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks 😄


/// A keyboard event, generated on every key press and key release.
#[derive(Debug, Clone, Copy)]
pub struct KeyEvent {
Expand Down
16 changes: 0 additions & 16 deletions druid-shell/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,6 @@
pub use kurbo;
pub use piet_common as piet;

#[cfg(target_os = "windows")]
#[macro_use]
extern crate winapi;

#[cfg(all(target_os = "macos", not(feature = "use_gtk")))]
#[macro_use]
extern crate objc;

#[cfg(not(any(feature = "use_gtk", target_os = "linux")))]
#[macro_use]
extern crate lazy_static;

#[cfg(all(target_os = "linux", feature = "x11"))]
#[macro_use]
extern crate lazy_static;

mod application;
mod clipboard;
mod common_util;
Expand Down
3 changes: 2 additions & 1 deletion druid-shell/src/platform/gtk/clipboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@

//! Interactions with the system pasteboard on GTK+.

use crate::clipboard::{ClipboardFormat, FormatId};
use gdk::Atom;
use gtk::{TargetEntry, TargetFlags};

use crate::clipboard::{ClipboardFormat, FormatId};

/// The system clipboard.
#[derive(Debug, Clone)]
pub struct Clipboard;
Expand Down
2 changes: 1 addition & 1 deletion druid-shell/src/platform/gtk/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

use std::ffi::OsString;

use crate::dialog::{FileDialogOptions, FileDialogType};
use gtk::{FileChooserAction, FileChooserExt, NativeDialogExt, ResponseType, Window};

use crate::dialog::{FileDialogOptions, FileDialogType};
use crate::Error;

pub(crate) fn get_file_dialog_path(
Expand Down
10 changes: 6 additions & 4 deletions druid-shell/src/platform/mac/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@

use std::ffi::c_void;

use super::clipboard::Clipboard;
use super::util;
use crate::application::AppHandler;

use cocoa::appkit::{NSApp, NSApplication, NSApplicationActivationPolicyRegular};
use cocoa::base::{id, nil, YES};
use cocoa::foundation::NSAutoreleasePool;
use lazy_static::lazy_static;
use objc::declare::ClassDecl;
use objc::runtime::{Class, Object, Sel};
use objc::{class, msg_send, sel, sel_impl};

use super::clipboard::Clipboard;
use super::util;
use crate::application::AppHandler;

static APP_HANDLER_IVAR: &str = "druidAppHandler";

Expand Down
1 change: 1 addition & 0 deletions druid-shell/src/platform/mac/clipboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use cocoa::appkit::NSPasteboardTypeString;
use cocoa::base::{id, nil, BOOL, YES};
use cocoa::foundation::{NSArray, NSInteger, NSUInteger};
use objc::{class, msg_send, sel, sel_impl};

use super::util;
use crate::clipboard::{ClipboardFormat, FormatId};
Expand Down
1 change: 1 addition & 0 deletions druid-shell/src/platform/mac/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::ffi::OsString;

use cocoa::base::{id, nil, YES};
use cocoa::foundation::{NSArray, NSInteger};
use objc::{class, msg_send, sel, sel_impl};

use super::util::{from_nsstring, make_nsstring};
use crate::dialog::{FileDialogOptions, FileDialogType};
Expand Down
1 change: 1 addition & 0 deletions druid-shell/src/platform/mac/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use cocoa::appkit::{NSEventModifierFlags, NSMenu, NSMenuItem};
use cocoa::base::{id, nil, NO};
use cocoa::foundation::NSAutoreleasePool;
use objc::{msg_send, sel, sel_impl};

use super::util::make_nsstring;
use crate::common_util::strip_access_key;
Expand Down
1 change: 1 addition & 0 deletions druid-shell/src/platform/mac/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use std::ffi::c_void;

use cocoa::base::{id, nil, BOOL, YES};
use cocoa::foundation::{NSAutoreleasePool, NSString, NSUInteger};
use objc::{class, msg_send, sel, sel_impl};

/// Panic if not on the main thread.assert_main_thread()
///
Expand Down
2 changes: 2 additions & 0 deletions druid-shell/src/platform/mac/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ use cocoa::appkit::{
};
use cocoa::base::{id, nil, BOOL, NO, YES};
use cocoa::foundation::{NSAutoreleasePool, NSPoint, NSRect, NSSize, NSString};
use lazy_static::lazy_static;
use objc::declare::ClassDecl;
use objc::rc::WeakPtr;
use objc::runtime::{Class, Object, Sel};
use objc::{class, msg_send, sel, sel_impl};

use cairo::{Context, QuartzSurface};
use log::{error, info};
Expand Down
7 changes: 4 additions & 3 deletions druid-shell/src/platform/windows/accels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@

//! Wrappers for Windows of Accelerate Table.

use std::collections::HashMap;
use std::sync::{Arc, Mutex};

use lazy_static::lazy_static;
use winapi::ctypes::c_int;
use winapi::shared::windef::*;
use winapi::um::winuser::*;

use std::collections::HashMap;
use std::sync::{Arc, Mutex};

// NOTE:
// https://docs.microsoft.com/en-us/windows/win32/wsw/thread-safety
// All handles you obtain from functions in Kernel32 are thread-safe,
Expand Down
5 changes: 3 additions & 2 deletions druid-shell/src/platform/windows/dcomp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
use std::mem;
use std::ops::{Deref, DerefMut};
use std::ptr::{null, null_mut};

use log::error;

use winapi::shared::dxgi::IDXGIDevice;
use winapi::shared::dxgi1_2::DXGI_ALPHA_MODE_IGNORE;
use winapi::shared::dxgiformat::DXGI_FORMAT_B8G8R8A8_UNORM;
Expand All @@ -38,8 +41,6 @@ use winapi::um::winnt::HRESULT;
use winapi::Interface;
use wio::com::ComPtr;

use log::error;

use super::util::OPTIONAL_FUNCTIONS;

unsafe fn wrap<T, U, F>(hr: HRESULT, ptr: *mut T, f: F) -> Result<U, HRESULT>
Expand Down
10 changes: 5 additions & 5 deletions druid-shell/src/platform/windows/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

#![allow(non_upper_case_globals)]

use std::convert::TryInto;
use std::ffi::OsString;
use std::ptr::null_mut;

use winapi::shared::minwindef::*;
use winapi::shared::ntdef::LPWSTR;
use winapi::shared::windef::*;
Expand All @@ -30,16 +34,12 @@ use winapi::um::combaseapi::*;
use winapi::um::shobjidl::*;
use winapi::um::shobjidl_core::*;
use winapi::um::shtypes::COMDLG_FILTERSPEC;
use winapi::Interface;
use winapi::{Interface, DEFINE_GUID};
use wio::com::ComPtr;

use super::error::Error;
use super::util::{as_result, FromWide, ToWide};
use crate::dialog::{FileDialogOptions, FileDialogType, FileSpec};
use std::ffi::OsString;
use std::ptr::null_mut;

use std::convert::TryInto;

// TODO: remove these when they get added to winapi
DEFINE_GUID! {CLSID_FileOpenDialog,
Expand Down
5 changes: 3 additions & 2 deletions druid-shell/src/platform/windows/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
//! Errors at the application shell level.

use std::fmt;

use super::util::FromWide;
use std::ptr::{null, null_mut};

use winapi::shared::minwindef::{DWORD, HLOCAL};
use winapi::shared::ntdef::LPWSTR;
use winapi::shared::winerror::HRESULT;
Expand All @@ -26,6 +25,8 @@ use winapi::um::winbase::{
FORMAT_MESSAGE_IGNORE_INSERTS, FORMAT_MESSAGE_MAX_WIDTH_MASK,
};

use super::util::FromWide;

/// Error codes. At the moment, this is little more than HRESULT, but that
/// might change.
#[derive(Debug, Clone)]
Expand Down
3 changes: 2 additions & 1 deletion druid-shell/src/platform/windows/timers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@

//! Timer state.

use crate::window::TimerToken;
use std::collections::BTreeSet;
use std::time::Instant;

use crate::window::TimerToken;

pub struct TimerSlots {
// Note: we can remove this when checked_duration_since lands.
next_fresh_id: u64,
Expand Down
1 change: 1 addition & 0 deletions druid-shell/src/platform/windows/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use std::os::windows::ffi::{OsStrExt, OsStringExt};
use std::ptr;
use std::slice;

use lazy_static::lazy_static;
use winapi::ctypes::c_void;
use winapi::shared::guiddef::REFIID;
use winapi::shared::minwindef::{HMODULE, UINT};
Expand Down
2 changes: 2 additions & 0 deletions druid-shell/src/platform/x11/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ use std::cell::RefCell;
use std::collections::HashMap;
use std::sync::Arc;

use lazy_static::lazy_static;

use super::clipboard::Clipboard;
use super::window::XWindow;
use crate::application::AppHandler;
Expand Down