1 module gui.cursor; 2 3 import utils; 4 import cboxapp; 5 import deimos.X11.X; 6 import deimos.X11.Xlib; 7 import deimos.X11.keysymdef; 8 import deimos.X11.Xutil; 9 import deimos.X11.Xatom; 10 import std.c.stdlib; 11 static Cur*[CurLast] cursor; 12 13 enum 14 { 15 CurNormal, 16 CurResize, 17 CurMove, 18 CurLast 19 }; /* cursor */ 20 21 enum CursorFont : int 22 { 23 XC_num_glyphs = 154, 24 XC_X_cursor = 0, 25 XC_arrow = 2, 26 XC_based_arrow_down = 4, 27 XC_based_arrow_up = 6, 28 XC_boat = 8, 29 XC_bogosity = 10, 30 XC_bottom_left_corner = 12, 31 XC_bottom_right_corner = 14, 32 XC_bottom_side = 16, 33 XC_bottom_tee = 18, 34 XC_box_spiral = 20, 35 XC_center_ptr = 22, 36 XC_circle = 24, 37 XC_clock = 26, 38 XC_coffee_mug = 28, 39 XC_cross = 30, 40 XC_cross_reverse = 32, 41 XC_crosshair = 34, 42 XC_diamond_cross = 36, 43 XC_dot = 38, 44 XC_dotbox = 40, 45 XC_double_arrow = 42, 46 XC_draft_large = 44, 47 XC_draft_small = 46, 48 XC_draped_box = 48, 49 XC_exchange = 50, 50 XC_fleur = 52, 51 XC_gobbler = 54, 52 XC_gumby = 56, 53 XC_hand1 = 58, 54 XC_hand2 = 60, 55 XC_heart = 62, 56 XC_icon = 64, 57 XC_iron_cross = 66, 58 XC_left_ptr = 68, 59 XC_left_side = 70, 60 XC_left_tee = 72, 61 XC_leftbutton = 74, 62 XC_ll_angle = 76, 63 XC_lr_angle = 78, 64 XC_man = 80, 65 XC_middlebutton = 82, 66 XC_mouse = 84, 67 XC_pencil = 86, 68 XC_pirate = 88, 69 XC_plus = 90, 70 XC_question_arrow = 92, 71 XC_right_ptr = 94, 72 XC_right_side = 96, 73 XC_right_tee = 98, 74 XC_rightbutton = 100, 75 XC_rtl_logo = 102, 76 XC_sailboat = 104, 77 XC_sb_down_arrow = 106, 78 XC_sb_h_double_arrow = 108, 79 XC_sb_left_arrow = 110, 80 XC_sb_right_arrow = 112, 81 XC_sb_up_arrow = 114, 82 XC_sb_v_double_arrow = 116, 83 XC_shuttle = 118, 84 XC_sizing = 120, 85 XC_spider = 122, 86 XC_spraycan = 124, 87 XC_star = 126, 88 XC_target = 128, 89 XC_tcross = 130, 90 XC_top_left_arrow = 132, 91 XC_top_left_corner = 134, 92 XC_top_right_corner = 136, 93 XC_top_side = 138, 94 XC_top_tee = 140, 95 XC_trek = 142, 96 XC_ul_angle = 144, 97 XC_umbrella = 146, 98 XC_ur_angle = 148, 99 XC_watch = 150, 100 XC_xterm = 152 101 } 102 103 /** 104 * Wraps a X cursor. 105 */ 106 struct Cur 107 { 108 Cursor cursor; 109 Display* dpy; 110 111 /** 112 * Ctor constructing a Cursor with a given display object. 113 * Params: 114 * dpy= Display object 115 * shape= X cursor shape 116 */ 117 this(Display* dpy, CursorFont shape) 118 { 119 if(dpy is null) { 120 // lout(__FUNCTION__~"\n\t--> NULL Display* parm"); 121 exit(EXIT_FAILURE); 122 } 123 this.dpy = dpy; 124 this.cursor = XCreateFontCursor(this.dpy, shape); 125 } 126 127 private void destroy() 128 { 129 XFreeCursor(this.dpy, this.cursor); 130 } 131 132 static void free(Cur* c) 133 { 134 if(c is null) { 135 // lout(__FUNCTION__~"\n\t--> NULL Cur* parm"); 136 exit(EXIT_FAILURE); 137 } 138 c.destroy(); 139 DGC.free(c); 140 } 141 142 }