X11 backend cursors support

This commit is contained in:
Vadim Lopatin 2015-12-02 15:11:23 +03:00
parent 304f882dd2
commit 1c5ca7757a
1 changed files with 102 additions and 0 deletions

View File

@ -36,6 +36,8 @@ private __gshared Atom atom_UTF8_STRING;
private __gshared Atom atom_CLIPBOARD;
private __gshared Atom atom_TARGETS;
private __gshared Cursor[CursorType.Hand + 1] x11cursors;
private GC createGC(Display* display, XWindow win)
{
GC gc; /* handle of newly created GC. */
@ -698,6 +700,12 @@ class X11Window : DWindow {
// sdlevent.user.windowID = windowId;
// SDL_PushEvent(&sdlevent);
}
/// sets cursor type for window
override protected void setCursorType(uint cursorType) {
XDefineCursor(x11display, _win, x11cursors[cursorType]);
XFlush(x11display);
}
}
private immutable int CUSTOM_EVENT = 32;
@ -1000,6 +1008,86 @@ class X11Platform : Platform {
}
}
enum {
XC_X_cursor=0,
XC_arrow=2,
XC_based_arrow_down=4,
XC_based_arrow_up=6,
XC_boat = 8,
XC_bogosity = 10,
XC_bottom_left_corner=12,
XC_bottom_right_corner=14,
XC_bottom_side=16,
XC_bottom_tee=18,
XC_box_spiral=20,
XC_center_ptr=22,
XC_circle=24,
XC_clock=26,
XC_coffee_mug=28,
XC_cross=30,
XC_cross_reverse=32,
XC_crosshair=34,
XC_diamond_cross=36,
XC_dot=38,
XC_dotbox=40,
XC_double_arrow=42,
XC_draft_large=44,
XC_draft_small=46,
XC_draped_box=48,
XC_exchange=50,
XC_fleur=52,
XC_gobbler=54,
XC_gumby=56,
XC_hand1=58,
XC_hand2=60,
XC_heart=62,
XC_icon=64,
XC_iron_cross=66,
XC_left_ptr=68,
XC_left_side=70,
XC_left_tee=72,
XC_leftbutton=74,
XC_ll_angle=76,
XC_lr_angle=78,
XC_man=80,
XC_middlebutton=82,
XC_mouse=84,
XC_pencil=86,
XC_pirate=88,
XC_plus=90,
XC_question_arrow=92,
XC_right_ptr=94,
XC_right_side=96,
XC_right_tee=98,
XC_rightbutton=100,
XC_rtl_logo=102,
XC_sailboat=104,
XC_sb_down_arrow=106,
XC_sb_h_double_arrow=108,
XC_sb_left_arrow=110,
XC_sb_right_arrow=112,
XC_sb_up_arrow=114,
XC_sb_v_double_arrow=116,
XC_shuttle=118,
XC_sizing=120,
XC_spider=122,
XC_spraycan=124,
XC_star=126,
XC_target=128,
XC_tcross=130,
XC_top_left_arrow=132,
XC_top_left_corner=134,
XC_top_right_corner=136,
XC_top_side=138,
XC_top_tee=140,
XC_trek=142,
XC_ul_angle=144,
XC_umbrella=146,
XC_ur_angle=148,
XC_watch=150,
XC_xterm=152,
}
extern(C) int DLANGUImain(string[] args)
{
initLogs();
@ -1031,6 +1119,20 @@ extern(C) int DLANGUImain(string[] args)
atom_CLIPBOARD = XInternAtom(x11display, "CLIPBOARD", False);
atom_TARGETS = XInternAtom(x11display, "TARGETS", False);
x11cursors[CursorType.None] = XCreateFontCursor(x11display, XC_arrow);
x11cursors[CursorType.Parent] = XCreateFontCursor(x11display, XC_arrow);
x11cursors[CursorType.Arrow] = XCreateFontCursor(x11display, XC_left_ptr);
x11cursors[CursorType.IBeam] = XCreateFontCursor(x11display, XC_xterm);
x11cursors[CursorType.Wait] = XCreateFontCursor(x11display, XC_watch);
x11cursors[CursorType.Crosshair] = XCreateFontCursor(x11display, XC_tcross);
x11cursors[CursorType.WaitArrow] = XCreateFontCursor(x11display, XC_watch);
x11cursors[CursorType.SizeNWSE] = XCreateFontCursor(x11display, XC_fleur);
x11cursors[CursorType.SizeNESW] = XCreateFontCursor(x11display, XC_fleur);
x11cursors[CursorType.SizeWE] = XCreateFontCursor(x11display, XC_sb_h_double_arrow);
x11cursors[CursorType.SizeNS] = XCreateFontCursor(x11display, XC_sb_v_double_arrow);
x11cursors[CursorType.SizeAll] = XCreateFontCursor(x11display, XC_fleur);
x11cursors[CursorType.No] = XCreateFontCursor(x11display, XC_pirate);
x11cursors[CursorType.Hand] = XCreateFontCursor(x11display, XC_hand2);
xim = XOpenIM(x11display, null, null, null);
if (!xim) {