Refine X11 cursor selections

For MouseCursor::Cell, NotAllowed, NoDrop, Grab, Grabbing, ... set the
appropriate X11 cursor.

Also alphabetize the cursors listed in the MouseCursor enum.
This commit is contained in:
Bryan Bell 2015-01-12 19:00:45 -08:00
parent b532b8c65f
commit 95f0990074

View file

@ -616,15 +616,21 @@ impl Window {
unsafe { unsafe {
use std::ffi::CString; use std::ffi::CString;
let cursor_name = match cursor { let cursor_name = match cursor {
MouseCursor::Default => "left_ptr", MouseCursor::Alias => "link",
MouseCursor::Crosshair => "crosshair",
MouseCursor::Hand => "hand",
MouseCursor::Arrow => "arrow", MouseCursor::Arrow => "arrow",
MouseCursor::Move => "fleur", MouseCursor::Cell => "plus",
MouseCursor::Text => "xterm", MouseCursor::Copy => "copy",
MouseCursor::Wait => "watch", MouseCursor::Crosshair => "crosshair",
MouseCursor::Default => "left_ptr",
MouseCursor::Grabbing => "grabbing",
MouseCursor::Hand | MouseCursor::Grab => "hand",
MouseCursor::Help => "question_arrow", MouseCursor::Help => "question_arrow",
MouseCursor::Progress => "watch", // TODO: Find better matching X11 cursor MouseCursor::Move => "move",
MouseCursor::NoDrop => "circle",
MouseCursor::NotAllowed => "crossed_circle",
MouseCursor::Progress => "left_ptr_watch",
/// Resize cursors
MouseCursor::EResize => "right_side", MouseCursor::EResize => "right_side",
MouseCursor::NResize => "top_side", MouseCursor::NResize => "top_side",
MouseCursor::NeResize => "top_right_corner", MouseCursor::NeResize => "top_right_corner",
@ -633,21 +639,18 @@ impl Window {
MouseCursor::SeResize => "bottom_right_corner", MouseCursor::SeResize => "bottom_right_corner",
MouseCursor::SwResize => "bottom_left_corner", MouseCursor::SwResize => "bottom_left_corner",
MouseCursor::WResize => "left_side", MouseCursor::WResize => "left_side",
MouseCursor::EwResize => "h_double_arrow", MouseCursor::EwResize | MouseCursor::ColResize => "h_double_arrow",
MouseCursor::NsResize => "v_double_arrow", MouseCursor::NsResize | MouseCursor::RowResize => "v_double_arrow",
MouseCursor::NwseResize => "bd_double_arrow",
MouseCursor::NeswResize => "fd_double_arrow",
MouseCursor::Text | MouseCursor::VerticalText => "xterm",
MouseCursor::Wait => "watch",
MouseCursor::NeswResize | MouseCursor::NwseResize => "sizing", // TODO: Better matching X11 cursor
MouseCursor::ColResize | MouseCursor::RowResize => "double_arrow", // TODO: Better matching X11 cursor
/// TODO: Find matching X11 cursors /// TODO: Find matching X11 cursors
MouseCursor::NotAllowed | MouseCursor::ContextMenu | MouseCursor::ContextMenu | MouseCursor::NoneCursor |
MouseCursor::NoneCursor | MouseCursor::Cell | MouseCursor::AllScroll | MouseCursor::ZoomIn |
MouseCursor::VerticalText | MouseCursor::Alias | MouseCursor::ZoomOut => "left_ptr",
MouseCursor::Copy | MouseCursor::NoDrop | MouseCursor::Grab |
MouseCursor::Grabbing | MouseCursor::AllScroll |
MouseCursor::ZoomIn | MouseCursor::ZoomOut => "left_ptr",
}; };
let c_string = CString::from_slice(cursor_name.as_bytes()); let c_string = CString::from_slice(cursor_name.as_bytes());
let xcursor = ffi::XcursorLibraryLoadCursor(self.x.display, c_string.as_ptr()); let xcursor = ffi::XcursorLibraryLoadCursor(self.x.display, c_string.as_ptr());