~ubuntu-branches/ubuntu/trusty/miwm/trusty

« back to all changes in this revision

Viewing changes to cursor.cc

  • Committer: Bazaar Package Importer
  • Author(s): Jari Aalto
  • Date: 2010-01-04 15:25:34 UTC
  • Revision ID: james.westby@ubuntu.com-20100104152534-l3fdvt162le460cv
Tags: upstream-1.1
ImportĀ upstreamĀ versionĀ 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//-*- c++ -*-
 
2
// -------------------------------------------
 
3
// RCS data:
 
4
// $Date: 2003/06/23 14:47:22 $
 
5
// $Revision: 1.1.1.1 $
 
6
// $Source: /cvsroot/miwm/miwm/miwm/cursor.cc,v $
 
7
// $Id: cursor.cc,v 1.1.1.1 2003/06/23 14:47:22 bwise837 Exp $
 
8
// $RCSfile: cursor.cc,v $
 
9
// -------------------------------------------
 
10
// Copyright by Ben Paul Wise.
 
11
// -------------------------------------------
 
12
// This program is free software; you can redistribute it and/or modify
 
13
// it under the terms of the GNU General Public License as published by
 
14
// the Free Software Foundation; either version 2 of the License, or
 
15
// (at your option) any later version.
 
16
// 
 
17
// This program is distributed in the hope that it will be useful,
 
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
// GNU General Public License for more details.
 
21
// 
 
22
// You should have received a copy of the GNU General Public License
 
23
// along with this program; if not, write to the Free Software
 
24
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
25
// -------------------------------------------
 
26
 
 
27
#include        <stdio.h>
 
28
 
 
29
#include        <X11/X.h>
 
30
#include        <X11/Xlib.h>
 
31
#include        <X11/Xutil.h>
 
32
#include        <X11/cursorfont.h>
 
33
 
 
34
#include "miwm.h"
 
35
 
 
36
Cursor root_cursor;
 
37
Cursor frame_cursor;
 
38
Cursor menu_cursor;
 
39
 
 
40
static struct CursorMapping {
 
41
  Edge          edge;
 
42
  int           font_char;
 
43
  Cursor        cursor;
 
44
} cursor_map[] = {
 
45
 
 
46
  /*
 
47
         * These *MUST* be in the same order as they appear in miwm.h, because
 
48
         * we index rather than search in edgecursor() later on.
 
49
         */
 
50
 
 
51
  {ETopLeft,            XC_top_left_corner, 0,},
 
52
  {ETop,                        XC_top_side, 0,},
 
53
  {ETopRight,           XC_top_right_corner, 0,},
 
54
  {ERight,                      XC_right_side, 0,},
 
55
  {ENone,                       XC_fleur, 0,},
 
56
  {ELeft,                       XC_left_side, 0,},
 
57
  {EBottomLeft, XC_bottom_left_corner, 0,},
 
58
  {EBottom,             XC_bottom_side, 0,},
 
59
  {EBottomRight,        XC_bottom_right_corner, 0,},
 
60
 
 
61
  {ENone,                       0, 0,},
 
62
};
 
63
 
 
64
extern void
 
65
initCursor(void) {
 
66
  //   XColor red;
 
67
  XColor exact;
 
68
  Colormap cmp;
 
69
  int i;
 
70
  // XC_crosshair, XC_X_cursor, XC_fleur are all reasonable for BPW
 
71
  cmp = DefaultColormap(dpy, DefaultScreen(dpy));
 
72
//   root_cursor = XCreateFontCursor(dpy, XC_X_cursor);
 
73
  root_cursor = XCreateFontCursor(dpy, XC_X_cursor);
 
74
  frame_cursor = XCreateFontCursor(dpy, XC_left_ptr);
 
75
  menu_cursor = XCreateFontCursor(dpy, XC_crosshair);
 
76
 
 
77
//   XRecolorCursor(dpy, root_cursor, &red, &exact);
 
78
  XRecolorCursor(dpy, root_cursor, &theWM->rootCursorColor, &exact);
 
79
  XRecolorCursor(dpy, menu_cursor, &theWM->frameCursorColor, &exact);
 
80
  XRecolorCursor(dpy, frame_cursor, &theWM->frameCursorColor, &exact);
 
81
 
 
82
  for (i = 0; cursor_map[i].font_char != 0; i++) {
 
83
    cursor_map[i].cursor = XCreateFontCursor(dpy, cursor_map[i].font_char);
 
84
    XRecolorCursor(dpy, cursor_map[i].cursor, &theWM->frameCursorColor, &exact);
 
85
  }
 
86
//   cout << "init cursor finished" << endl << flush;
 
87
  return;
 
88
}
 
89
 
 
90
extern Cursor
 
91
edgecursor(Edge edge) {
 
92
  return cursor_map[(int)edge].cursor;
 
93
}
 
94
 
 
95
 
 
96
// -------------------------------------------
 
97
// end of cursor.cc
 
98
// -------------------------------------------