~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/X11/tw_cursor.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**@(#)Cursor handling.
  2 **/
  3 
  4 /* A set of cursors is created as needed for each display used.  They
  5  * are stored in  a database accessed by display.  To set a cursor,
  6  * call tw_cursor_set with a Tina_cursor_type argument. */
  7 
  8 #include <stdio.h>
  9 #include <math.h>
 10 #include <tina/sys.h>
 11 #include <tina/sysfuncs.h>
 12 #include <tina/math.h>
 13 #include <tina/tv.h>
 14 #include <tina/tv_screen.h>
 15 #include <X11/Xlib.h>
 16 #include <X11/cursorfont.h>
 17 
 18 
 19 typedef struct cursor_data
 20 {
 21     Display *display;
 22     Cursor  cursor_array[zz_ncursors];
 23 }       Cursor_data;
 24 
 25 static void *cursor_match(Display * display, Cursor_data * data)
 26 {
 27     return (display == data->display) ? (void *) data : NULL;
 28 }
 29 
 30 static Cursor *tw_find_cursors(Display * display)
 31 {
 32     Cursor_data *cursor_data = NULL;
 33     Cursor *cursor_array;
 34     static List *cursor_database = NULL;
 35 
 36     if (display)
 37     {
 38         cursor_data = (Cursor_data *) list_query(cursor_database, cursor_match,
 39                                                  (void *) display);
 40         if (cursor_data)
 41         {
 42             cursor_array = cursor_data->cursor_array;
 43         } else
 44         {
 45             cursor_data = ts_ralloc(Cursor_data);
 46             cursor_data->display = display;
 47             cursor_array = cursor_data->cursor_array;
 48             cursor_array[(int) mouse_cursor] = XCreateFontCursor(display, XC_crosshair);
 49             cursor_array[(int) null_cursor] = XCreateFontCursor(display, XC_left_ptr);
 50             cursor_array[(int) pick_cursor] = XCreateFontCursor(display, XC_hand1);
 51             cursor_array[(int) roi_cursor] = XCreateFontCursor(display, XC_dotbox);
 52             cursor_array[(int) tina_cursor] = XCreateFontCursor(display, XC_left_ptr);
 53             cursor_array[(int) wait_cursor] = XCreateFontCursor(display, XC_watch);
 54             cursor_array[(int) zoom_cursor] = XCreateFontCursor(display, XC_fleur);
 55 
 56             cursor_database = ref_addtostart(cursor_database, (void *) cursor_data, 0);
 57         }
 58     }
 59     return cursor_array;
 60 }
 61 
 62 
 63 void    tw_cursor_set(Display * display, Window window, Tina_cursor_type cursor_type)
 64 {
 65     extern void tw_flush(void);
 66 
 67     if (display && window)
 68     {
 69         Cursor *cursor_array = tw_find_cursors(display);
 70 
 71         XDefineCursor(display, window, cursor_array[(int) cursor_type]);
 72         tw_flush();
 73     }
 74 }
 75 
 76 
 77 void    tw_set_tina_cursor(Display * display, Window window)
 78 {
 79     tw_cursor_set(display, window, tina_cursor);
 80 }
 81 
 82 
 83 void    tw_set_wait_cursor(Display * display, Window window)
 84 {
 85     tw_cursor_set(display, window, wait_cursor);
 86 }
 87 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.