home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / windows / x / 20720 < prev    next >
Encoding:
Internet Message Format  |  1993-01-04  |  2.9 KB

  1. Path: sparky!uunet!mcsun!uknet!lsl!snail
  2. From: snail@lsl.co.uk
  3. Newsgroups: comp.windows.x
  4. Subject: Re: How to let the pointer disappeared?
  5. Message-ID: <1993Jan4.165028.2882@lsl.co.uk>
  6. Date: 4 Jan 93 16:50:28 GMT
  7. References: <1992Dec25.181545.21726@sparc4.ncu.edu.tw>
  8. Organization: Laser-Scan Ltd., Cambridge
  9. Lines: 78
  10.  
  11. In article <1992Dec25.181545.21726@sparc4.ncu.edu.tw>, u438813@ba.ncu.edu.tw (Lin Wei-Ting) writes:
  12. > I want to let the pointer disaooeared when the pointer enters a canvas.
  13. > How should I do ?
  14. > Thanks..
  15.  
  16. Create a pixmap which has no pixels set in it. Do this using 
  17.  
  18.    Pixmap  pixmap;
  19.    Display *display;
  20.    Window  window;
  21.    char    *bitmapdata;
  22.    int     width, height;
  23.  
  24.    pixmap = XCreatePixmapFromBitmapData(display,
  25.                                         window,
  26.                                         bitmapdata,
  27.                                         width, height,
  28.                                         (unsigned long)1, (unsigned long)0,
  29.                                         1);
  30.  
  31. Note that if bitmapdata points to some memory that contains all 0 data then
  32. this provides you with no pixels set in it. Set Width and Height as
  33. appropriate.
  34.  
  35. Now (for completeness) get the foreground and background colours...
  36. This is not needed if you're setting a blank pixmap, but really your code
  37. should be reusable and this lot should be part of something greater....
  38.  
  39.    Screen *screen;
  40.    XColor bg, fg;
  41.  
  42.    screen = ScreenOfDisplay(con_get_frontend_display(),
  43.                             DefaultScreen(con_get_frontend_display()));
  44.    fg.pixel = BlackPixelOfScreen(screen);
  45.    bg.pixel = WhitePixelOfScreen(screen);
  46.  
  47.    if (fg.pixel == bg.pixel)
  48.    {
  49.       printf("Black and white default pixels are the same");
  50.  
  51.       /* handle your error here */
  52.  
  53.       return;
  54.    }
  55.  
  56.    fg.flags = (char)(DoRed | DoGreen | DoBlue);
  57.    bg.flags = (char)(DoRed | DoGreen | DoBlue);
  58.  
  59.    /* now query to get the correct RGB for these pixel values, we       */
  60.    /* query the default colour map                                      */
  61.  
  62.    XQueryColor(con_get_frontend_display(),
  63.                DefaultColormap(con_get_frontend_display(),
  64.                                DefaultScreen(con_get_frontend_display())),
  65.                &bg);
  66.  
  67. Then set this pixmap as the pixmap cursor using
  68.  
  69. int hotspot_x, hotspot_y;
  70.  
  71. XCreatePixmapCursor(display, pixmap, pixmap,
  72.                     &fg,
  73.                     &bg,
  74.                     hotspot_x, hotspot_y);
  75.  
  76. hotspot_x and hotspot_y specify where the hotspot goes, often set this to
  77. width/2 and height/2 respectively.
  78.  
  79. OK? All this has been selected and edited from code we have here.... at least
  80.     I don't think I've added typos in the editing..
  81. -- 
  82. snail@lsl.co.uk      
  83.  
  84. "Washing one's hands of the conflict between the powerful and the powerless
  85.  means to side with the powerful, not to be Neutral."
  86.                                                      Quote by Freire.
  87.                                                      Poster by OXFAM.
  88.