wmi

git clone git://oldgit.suckless.org/wmi/
Log | Files | Refs | LICENSE

cursors.cpp (1808B)


      1 // Copyright (c) 2003 - 2009 Anselm R Garbe <anselm@garbe.us>
      2 // See LICENSE for license details.
      3 
      4 extern "C" {
      5 #include <X11/cursorfont.h>
      6 }
      7 
      8 #include "cursors.h"
      9 
     10 #include "kernel.h"
     11 #include "wmi.h"
     12 #include "xcore.h"
     13 
     14 Cursor Cursors::NORMAL_CURSOR = 0;
     15 Cursor Cursors::RESIZE_LEFT_CURSOR = 0;
     16 Cursor Cursors::RESIZE_RIGHT_CURSOR = 0;
     17 Cursor Cursors::RESIZE_UP_CURSOR = 0;
     18 Cursor Cursors::RESIZE_DOWN_CURSOR = 0;
     19 
     20 Cursor Cursors::RESIZE_NORTH_WEST_CURSOR = 0;
     21 Cursor Cursors::RESIZE_NORTH_EAST_CURSOR = 0;
     22 Cursor Cursors::RESIZE_SOUTH_EAST_CURSOR = 0;
     23 Cursor Cursors::RESIZE_SOUTH_WEST_CURSOR = 0;
     24 
     25 bool Cursors::initialized_ = false;
     26 
     27 void Cursors::cleanup() {
     28 
     29     XCORE->freeCursor(NORMAL_CURSOR);
     30     XCORE->freeCursor(RESIZE_LEFT_CURSOR);
     31     XCORE->freeCursor(RESIZE_RIGHT_CURSOR);
     32     XCORE->freeCursor(RESIZE_UP_CURSOR);
     33     XCORE->freeCursor(RESIZE_DOWN_CURSOR);
     34 
     35     XCORE->freeCursor(RESIZE_NORTH_WEST_CURSOR);
     36     XCORE->freeCursor(RESIZE_NORTH_EAST_CURSOR);
     37     XCORE->freeCursor(RESIZE_SOUTH_WEST_CURSOR);
     38     XCORE->freeCursor(RESIZE_SOUTH_EAST_CURSOR);
     39 }
     40 
     41 void Cursors::initCursors()
     42 {
     43     if (initialized_) {
     44         return;
     45     }
     46 
     47     NORMAL_CURSOR = XCORE->createFontCursor(XC_left_ptr);
     48     RESIZE_LEFT_CURSOR = XCORE->createFontCursor(XC_left_side);
     49     RESIZE_RIGHT_CURSOR = XCORE->createFontCursor(XC_right_side);
     50     RESIZE_UP_CURSOR = XCORE->createFontCursor(XC_top_side);
     51     RESIZE_DOWN_CURSOR = XCORE->createFontCursor(XC_bottom_side);
     52 
     53     RESIZE_NORTH_WEST_CURSOR = XCORE->createFontCursor(XC_top_left_corner);
     54     RESIZE_NORTH_EAST_CURSOR = XCORE->createFontCursor(XC_top_right_corner);
     55     RESIZE_SOUTH_WEST_CURSOR = XCORE->createFontCursor(XC_bottom_left_corner);
     56     RESIZE_SOUTH_EAST_CURSOR = XCORE->createFontCursor(XC_bottom_right_corner);
     57 
     58     initialized_ = true;
     59 }